IEEE 754 binary32 and binary64

Read the fields from the most significant bit. Classify the exponent code before calculating a value.

Field positions

Field or parameterbinary32binary64
C type on the lab targetfloatdouble
Sign sBit 31Bit 63
Stored exponent BBits 30 to 23Bits 62 to 52
Fraction field FBits 22 to 0Bits 51 to 0
Fraction width t2352
Exponent bias1271023
All-ones exponent code2552047
Precision for normal values24 bits53 bits
Actual normal exponent range−126 to +127−1022 to +1023

Decode by exponent code

Read the fraction field as an unsigned integer F. The fraction is f = F / 2t. The full significand is 1 + f for normals and f for subnormals. For signed values, s = 0 is positive and s = 1 is negative.

Exponent code BFraction ClassValue
ZeroZeroSigned zero+0 or −0
ZeroNonzeroSubnormal (−1)s × f × 21 − bias
Between zero and all onesAnyNormal (−1)s × (1 + f) × 2B − bias
All onesZeroInfinity+∞ or −∞
All onesNonzeroNaNNot a number

Binary32 landmarks

WordMeaning
0x80000000−0
0x00000001Smallest positive subnormal, 2−149
0x00800000Smallest positive normal, 2−126
0x3f8000001.0
0x7f7fffffLargest finite positive value, (2 − 2−23) × 2127
0x7f800000+∞
0x7fc00000One quiet NaN encoding on x86

Within one normal exponent, adjacent fraction codes differ in magnitude by 2B − bias − t. On x86, the least significant byte comes first in memory.