Re: 64 bit assignment on a 32 bit platform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kum writes:
 > Hi,
 > 
 > UINT64 a64; // UINT64 has been typedefed as long long unsigned int
 > UINT32 a32, b32;
 > a32 = x; // some value
 > b32 = y; // some value
 > 
 > a64 = a32 * b32;
 > a64 += a32 + b32;
 > 
 > Is it necessary to type-cast both a32 and b32 to yield correct 64 bit
 > results? Without casting, I find that addition (even if the result
 > overflows) works while the multiplication does not. Is there a
 > compiler option to make this work without casting? I am using gcc
 > 4.1.1 on an xscale platform.

You have to cast at leat one of the operands in a binary operation to
get the widening to anything wider than int.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux