I am quite a newbie to c. So when i writing a small game demo, i face a really strange problem.
void testC()
{
float a = 825300160;
float b = a +
The fractional portion of a float
consists of 23 bits. You need 30 bits to represent 825300160, so the less significant portion of the number is dropped. Adding .1
does not make a difference - you need to add roughly 32
for the number to change:
float a = 825300160;
float b = a + 31.5;
assert(a != b); // No change is detected
float c = a + 32;
assert(a != c); // Change is detected