Testing atoi I have noticed that from 2 ^ 63 returns 0 if the number that should return is negative, and -1 if the number that should return is positive, someone has an idea why?
Testing atoi I have noticed that from 2 ^ 63 returns 0 if the number that should return is negative, and -1 if the number that should return is positive, someone has an idea why?
The purpose of the int atoi (const char * str)
function is to convert a string representing an integer to an integer. As documented here , if the converted figure falls outside the range that a int
can represent ( LONG_MIN
and LONG_MAX
defined in limits.h
) then the behavior is undefined.
It will then depend on the compiler you are using to know the reason for the observed behavior.