This is a simple code to demonstrate how double is stored in computer Memory.
展示双精度和单精度浮点数在计算机内存中存储方式的简单代码
To Understand the concept, please read details in the link below.
理解概念请参考:https://receiverhelp.trimble.com/oem-gnss/index.html#API_FloatingPointDataTypes.html.
Example Output(使用例子):
[root@localhost ~]# gcc ShowDoubleConversion.c -lm
[root@localhost ~]# ./a.out
Please enter a double number: 7464.1648
Double: 7464.164800
RawDouble: 40BD282A30553261
Dec Form:
*****************
Sign: 0
Exponent: 1035
Fraction: 3703336361865825
Hex Form:
*****************
Sign: 0
Exponent: 40B
Fraction: D282A30553261
Conversion:
*****************
Sign: Positive
Exponent: 12
Binary Fraction: 1101001010000010101000110000010101010011001001100001
Decimal Fraction: 1.822306
Raw Double in Decimal Calculation: 7464.164800=1x1.822306x2^12
Double Check Answer: 7464.164800
[root@localhost ~]#