Answer the question
In order to leave comments, you need to log in
How to see float or double in binary format?
How to represent float or double in binary format?
Answer the question
In order to leave comments, you need to log in
$ cat > dump-fp.c <<EOF
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
void dump_float(float v)
{
uint32_t i;
memcpy(&i, &v, sizeof(i));
printf("0x%08"PRIx32"\n", i);
}
void dump_double(double v)
{
uint64_t i;
memcpy(&i, &v, sizeof(i));
printf("0x%016"PRIx64"\n", i);
}
int main(void)
{
dump_float(1.0f);
dump_double(1.0l);
return 0;
}
EOF
$ gcc dump-fp.c -o dump-fp
$ ./dump-fp
0x3f800000
0x3ff0000000000000
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question