I am working on float numbers as part of my project and I ran into this issue. I have two floats that are different. However, when I try to print them, it prints the same value. Can someone please help me understand what's happening? Is it related to the number of fractional digits that can be printed on the console?
Following is the MWE.
#include<stdint.h>
#include<iostream>
union FP32 {
float f;
uint32_t bits;
};
int main(void) {
FP32 a, b;
a.bits = 0x40800000;
b.bits = 0x407FFFFF;
std::cout << a.f << std::endl;
std::cout << b.f << std::endl;
return 1;
}