I'm a beginner so there may be things wrong here.
I need to do thousands of calculations with data (decimal numbers float) of several giant csv files, so I figured that using the binary in the ieee754 standard would avoid conversion and this would save time.
This was my test:
#include <stdio.h>
int main()
{
float a = 0b00111111110000000000000000000000; /* 1.5 */ /* uint32_t !? */
float b = 0b00111111110000000000000000000000; /* 1.5 */ /* uint32_t !? */
float c;
c = a + b; /* 3.0 !? */
printf("a: %f\n", a);
printf("b: %f\n", b);
printf("a+b: %f\n", c);
return 0;
}
It returns me:
a: 1069547520.000000
b: 1069547520.000000
a+b: 2139095040.000000
I realized that the value is integer, it seems to me that I should use uint32_t
, it added up the two integer values that returned 2139095040
.
This 2139095040
value that returned left me confused it is ieee754 ? I can convert to decimal 3.0
I expected to return the default binary ieee754 01000000010000000000000000000000
and thus could convert to decimal again.
Finally, how can I use ieee754 binary data to do arithmetic operations and return the resulting value in binary and decimal in order to get more processing speed?