Fun with float
Anyone want to hazard a guess as to what this C program prints as output? I'm running it on Mac OS/X 10.6.1 on an Intel Core 2 Duo processor, but this should be IEEE-754-compliant math and return the same results on any processor you like that uses IEEE-754.
#include <stdio.h>
int main(int argc, char *argv[])
{
float basenum = 16777210.0;
float num = 0.0;
int counter = 0;
for(counter=0; counter < 16; counter++) {
num = basenum + counter;
printf("num is: %f\n", num);
}
}
Labels: C 32-bit float math