QuickCoderHub

IEEE 754 VISUALIZER

BINARY FLOATING-POINT ANATOMY — 32 & 64 BIT

Input
PRECISION:
Bit Layout — click any bit to toggle
■ Sign (1 bit) ■ Exponent (8 bits) ■ Mantissa (23 bits)
Result
DECODED VALUE
3.1415927
Component Breakdown
Sign Bit
0
Positive (+1)
Exponent
10000000
Mantissa
Special Values — click to load
How It Works

A plain-English guide to IEEE 754 floating point

When you write 3.14 or 0.1 in a program, your computer stores it as a pattern of bits. Almost every modern CPU, phone and GPU uses the same pattern, defined by the IEEE 754 standard (first published in 1985 and revised in 2008 and 2019). The visualizer above lets you see that pattern for yourself: type a decimal, paste a hex value or click individual bits, and it shows exactly how the number is stored.

The three parts of a floating-point number

A floating-point number works like scientific notation, but in binary. Instead of 6.02 × 10²³, the computer stores a sign, an exponent and a fraction (called the mantissa or significand):

For a normal number, the value is (−1)sign × 1.mantissa × 2(exponent − bias). The leading 1 is not stored because it is always there, which is how a float gets 24 bits of precision from 23 stored bits (and a double gets 53 from 52).

Worked example: how π becomes 0x40490FDB

  1. π is positive, so the sign bit is 0.
  2. 3.14159… equals 1.5707963 × 21, so the exponent is 1. Add the bias: 1 + 127 = 128, which is 10000000 in binary.
  3. The fractional part, 0.5707963, becomes 23 binary digits: 10010010000111111011011.
  4. Join them: 0 10000000 10010010000111111011011. Grouped in fours that is 0100 0000 0100 1001 0000 1111 1101 1011, or 0x40490FDB.

Twenty-three bits cannot hold every digit of π, so the stored value is really 3.14159274…, not 3.14159265…. That tiny gap is why the tool shows 3.1415927 in 32-bit mode.

Why 0.1 + 0.2 is not exactly 0.3

In decimal, 1/3 becomes 0.3333… and never ends. In binary, 0.1 has the same problem: it becomes the repeating pattern 0.0001100110011…, so the computer has to cut it off and store a close neighbour instead. Add 0.1 and 0.2 in double precision and you get 0.30000000000000004. This is not a bug in your language. JavaScript, Python, C++ and Java all give the same answer because they all follow IEEE 754. To see it, switch to 64-bit mode, enter 0.1, and look at the repeating 9s in the hex value 0x3FB999999999999A.

Special values

Two exponent patterns are reserved. When the exponent is all 0s, the number is zero or subnormal. Subnormals drop the implied leading 1 so values can fade gradually toward zero instead of jumping straight to it. When the exponent is all 1s, the number is infinity (mantissa all 0s) or NaN, short for Not a Number (mantissa not all 0s). Infinity appears on overflow, such as 1e39 stored in a float, and NaN appears from operations like 0 ÷ 0. There are also two zeros, +0 and −0. They compare equal, but 1 ÷ −0 gives −∞, and NaN is never equal to anything, not even itself.

ValueFloat (32-bit) hexDouble (64-bit) hex
+00x000000000x0000000000000000
−00x800000000x8000000000000000
+∞0x7F8000000x7FF0000000000000
−∞0xFF8000000xFFF0000000000000
NaN (quiet)0x7FC000000x7FF8000000000000
Smallest subnormal0x00000001 (≈ 1.4 × 10⁻⁴⁵)0x0000000000000001 (≈ 4.9 × 10⁻³²⁴)
Smallest normal0x00800000 (≈ 1.18 × 10⁻³⁸)0x0010000000000000 (≈ 2.23 × 10⁻³⁰⁸)
Largest finite0x7F7FFFFF (≈ 3.40 × 10³⁸)0x7FEFFFFFFFFFFFFF (≈ 1.80 × 10³⁰⁸)

How much precision do you get?

PropertyFloat (32-bit)Double (64-bit)
Significant bits2453
Decimal digitsabout 7about 15 to 16
Machine epsilon2⁻²³ ≈ 1.19 × 10⁻⁷2⁻⁵² ≈ 2.22 × 10⁻¹⁶
Integers exact up to2²⁴ = 16,777,2162⁵³ = 9,007,199,254,740,992

Past those integer limits the format can no longer count by ones. Enter 16777217 in 32-bit mode and it rounds to 16777216.

Common mistakes

Try it yourself

  1. Enter 0.1 in 32-bit mode, then switch to 64-bit mode and compare the two hex values.
  2. Enter 16777217 in 32-bit mode and watch it round.
  3. Enter 1e39 in 32-bit mode and see it overflow to infinity.
  4. Click the lowest exponent bit and watch the value double or halve.

Frequently asked questions

Should I use float or double?
Double is the default in languages like JavaScript and Python and is the safe choice for general work. Float uses half the memory and is common in graphics and machine learning, where about 7 digits of precision are enough.
Why is the exponent stored with a bias?
The bias lets the exponent be stored as an ordinary unsigned number. As a bonus, positive floats then sort in the same order as their bit patterns, which makes comparisons fast.
Does this tool send my numbers anywhere?
No. All the calculations run locally in your browser.

Verify You're Human

Copied!

We use cookies to enhance your experience. Optional cookies only run if you consent. See our Privacy Policy.