I want to store an float value in an integer variable and print that integer variable and i want to see the float value itself. Can it be done or not ?
If you want to see the bit pattern of your float
variable you could do this:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
int main(void) {
uint8_t bitpattern[sizeof (float)];
float f = 3.1414;
memcpy(bitpattern, &f, sizeof (float));
for (int i = 0; i < sizeof (float); i++)
printf("%02x ", bitpattern[i]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With