Thank you very much for your replies!
I found another solution from Internet just now by using 'union'
union four_byte
{
int i;
float f;
} share;
share.f = 2.34;
Then, I can access share.i as an integer. This seems easier.
Is that ok?
User Profile
Collapse
-
how to check each bit of a float
The 32-bit float number is defined by IEEE 754.
Given a float variable, f, how to check whether each of the 32 bits is '1' or '0'?
One possible solution is access f as a 32-bit int.
That is define an integer i that accesses the same memory address where f is stored.
Then, I can right shift i by one bit for 32 times and check whether the least significant bit is '1' or '0'.
But how to let i and f share the...
No activity results to display
Show More
Leave a comment: