You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently developing a function that converts a list of values to integers. In the case of float types, we have the convenient float8in_internal_null() function at toFloatList(), which returns the appropriate float value if the conversion is successful, but returns NULL if the conversion of a list element fails.
However, when working with integers and using the atoi() function, I encountered a limitation. Unlike float8in_internal_null(), atoi() does not return NULL when it fails to convert an element of the list to an integer. Instead, it returns 0.
Is there an alternative function within some library in AGE, that can help me achieve the desired behavior of returning NULL when a conversion to an integer is not possible? I would appreciate any guidance on this matter.
The PR of the toFloatList() function implemented is #1016
The text was updated successfully, but these errors were encountered:
I believe you encountered this problem to make a double check about the input what if it is zero and how to differentiate between the input is zero or the conversion was valid if that's the case then you can use an end pointer passed to the Atoi() then check in case of successful conversion the end pointer points to the null terminated string-"\0" other than this will be an error or un successful conversion.
I don't think there is an alternative function available in the AGE library. In your function, it may be easier if you just change the condition when using atoi() to check for the value 0 instead of NULL since the function will always return 0 when it fails in the conversion. For example:
I am currently developing a function that converts a list of values to integers. In the case of float types, we have the convenient
float8in_internal_null()
function attoFloatList()
, which returns the appropriate float value if the conversion is successful, but returns NULL if the conversion of a list element fails.However, when working with integers and using the
atoi()
function, I encountered a limitation. Unlikefloat8in_internal_null()
,atoi()
does not return NULL when it fails to convert an element of the list to an integer. Instead, it returns 0.Is there an alternative function within some library in AGE, that can help me achieve the desired behavior of returning NULL when a conversion to an integer is not possible? I would appreciate any guidance on this matter.
The PR of the
toFloatList()
function implemented is #1016The text was updated successfully, but these errors were encountered: