I am writing a simple function to check the 1's compliment of a floating number. This is the code I have written to verify the value:
#include <stdio.h>
#include <stdint.h>
int main()
{
float input = 25.456;
printf("input val = %f\n",input);
uint32_t temp = (uint32_t)input;
uint32_t toggleval = ~temp;
uint32_t checker = ~toggleval;
float output = (float)checker;
printf("output val = %f\n",output);
return 0;
}
After running this code, I can see the output as
input val = 25.455999
output val = 25.000000
Why are those decimal places different? I am expecting the same values as the input float value? Anything wrong here?