atoi and 9223372036854775808 (2 ^ 63)

-1

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?

    
asked by latiagertrutis 13.11.2017 в 02:31
source

1 answer

1

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.

    
answered by 13.11.2017 в 03:21