I need to convert double value to hex value;
#include <stdio.h>
#include <stdint.h>
uint64_t DoubleToHexCoverter(double f);
int main()
{
a = 40.123456789;
printf("Hex: %08x",DoubleToHexCoverter(a));
return 0;
}
uint64_t DoubleToHexCoverter(double d)
{
return (*(unsigned int*)&d);
}
I get this result:
Hex: 000000006e9b9cb2
I see half of the numbers. Other's full with zeros "00000000" How can I get all numbers correctly. I think uint64 value's keeping 32 bit + 32 bit values but I didnt do that please help me.
When I try below codes I get same result. EDIT:
uint64_t DoubleToHexCoverter(double f)
{
return (*(uint64_t*)&f);
}