c++ - Why can't I directly set an __int64 variable to -2500000000? -


this program written in vc++ 6.0 on windowsxp machine.

if try set __int64 variable -2500000000 directly, truncated 32bit value , two's complement taken.

__int64 testval; testval = -2500000000; 

at point testval equals 1794967293 (110 1010 1111 1101 0000 0111 0000 0000 binary).

when set variable 2500000000 , multiply negative one, works:

__int64 testval; testval = 2500000000; testval *= -1; 

the variable testval equals -2500000000 (1001 0101 0000 0010 1111 1001 0000 0000 binary).

any ideas? thanks.

get newer compiler. vc6 standard compliance poor.

in vc6, try suffix of i64, in

__int64 toobig = -2500000000i64; 

found the documentation!


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -