[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_number2int
- From: "Brian Weed" <bw@...>
- Date: Tue, 14 Nov 2006 16:12:04 -0500
Jerome Vuarand wrote:
Here I get this:
% gcc --version
gcc (GCC) 3.4.4 (mingw special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% cat test.c
printf("0x%08x\n", (int)(unsigned int)(double)0xffffffff);
printf("%d\n", (int)(unsigned int)(double)-4.0);
% make test
As you can see with your additionnal unsigned int cast you lose all negative values. That's because (unsigned int)0xffffffff and (int)0xffffffff have two different representations in double precision floating point format.
I get different results in VS2005...
Perhaps there is a compiler setting for choosing the float rounding