hurry wrote:
> hi,
>
> I am writing a c program in VC++ 6.
[...]
>
> when "c" returns value to "b" it becomes __int32 format.
> 9007199237963776 becomes -16777216
>
[...]
> __int64 c()
> {
> __int64 y;
> y = 9007199237963776;
> return y;
> }
[...]
__int64, and __int32 might be windows/VC specific data types and not std
C. So I am assuming all it is trying to represent is integer types of 64
bit and 32 bit long.
From what's provided in the post, the problem might be in the
statement: y = 9007199237963776;
The answer lies in sizeof(int) on your system(and compiler, of course.)
9007199237963776 is an integer constant of type 'int'.
1FFFFFFF000000 which is more than 32 bits and so this might be getting
truncated even before getting assigned to y.
You can try doing, instead,
y = 9007199237963776L; or
y = 9007199237963776LL;
--
(Welcome)
http://www.ungerhu.com/jxh/clc.welcome.txt
(clc FAQ)
http://c-faq.com