Float to Int Conversions
Stephen Pisuk
smp@ll.mit.edu
Tue Feb 26 08:14:00 GMT 2002
Hello,
I have a question regarding the conversion of floats
to integers. The problem is that GCC (version 2.95
3.0.2) produce different results than Microsoft's Visual Studio
6.0. First of all, its a matter of who is right, and then
second can they be made consistent.
For example
double x = pow(2,32) + 10;
unsigned int y = ((unsigned int) x);
Under MS VS y = 10
however under linux with GCC y=2^31 or 0x80000000
I assume the difference is in how the FPU control
word is set with the various error masks.
Is there any way so alter the functionality of GCC
to produce the first result?
Any help would be greatly appreciated. We write code
under both platforms, and its less of an issue of who
is right or wrong, but rather consistency.
Thanks
__________________________________________________
Stephen Pisuk
MIT Lincoln Laboratory, Room C-472
244 Wood St., Lexington, MA 02420-9108
voice: (781)-981-3682 fax: (781)-981-4583
e-mail: smp@ll.mit.edu
More information about the Gcc-help
mailing list