#include <stdio.h>
int main () {
float a = 123.0;
unsigned char ch, *cp;
ch = 0xff;
cp = (unsigned char *) &a;
printf ("%02x", ch&(*(cp+3)));
printf ("%02x", ch&(*(cp+2)));
printf ("%02x", ch&(*(cp+1)));
printf ("%02x\n", ch&(*(cp+0)));
/*I have written this program to see binary representation, but I can not understand the output, the binary representation?
}
#include <stdio.h> int main () { float a = 123.0; unsigned char ch, *cp;
Share
See Wikipedia: http://en.wikipedia.org/wiki/Single_precision_floating-point_format, which describes single precision floating point (a typical C
float, but depends on the compiler) as a 1-bit sign, 8-bit biased exponent, and 24-bit mantissa (23-bits stored).For your example: