OSDK C compiler : are floats supported?
Posted: Wed Apr 10, 2019 3:46 am
Hello kitties,
While attempting to use float values in my program I encountered a few weird issues with numerical values which led me to wonder if float values were correctly supported by the C compiler of the OSDK.
In order to verify that floats were properly supported I wrote the following program:
and... it turns out that well, floats are mostly non working. (Cf attached image below.)
Especially, conversions between integer values and floats seem to produce complete gibberish.
Is this a known limitation of the compiler or is this a bug?
While attempting to use float values in my program I encountered a few weird issues with numerical values which led me to wonder if float values were correctly supported by the C compiler of the OSDK.
In order to verify that floats were properly supported I wrote the following program:
Code: Select all
{
long testl = 224;
float testlf = (float)testl;
long clockl = clock();
float clockf = 123;
float clocklf = clockl;
float seconds = clockf / (float)CLOCKS_PER_SEC;
float seconds2 = clockf / CLOCKS_PER_SEC;
clock_t TIME0, TIME1;
printf("testl: %d\n", testl);
printf("testlf: %f\n", testlf);
printf("clockl: %d\n", clockl);
printf("clockf: %f\n", clockf);
printf("clocklf: %f\n", clocklf);
printf("seconds: %f\n", seconds);
printf("seconds2: %f\n", seconds2);
TIME0 = clock();
{
int a=0;
int i;
for (i = 0; i < 0x7FF; ++i)
{
printf("a:%d \r", a);
a++;
}
printf("\n");
}
TIME1 = clock();
printf("duration : %fs\n", (double)( TIME1-TIME0 ) / CLOCKS_PER_SEC);
}
Especially, conversions between integer values and floats seem to produce complete gibberish.
Is this a known limitation of the compiler or is this a bug?