Skip to content
AgileLogics

IEEE-754 Analysis

Breaks a number down into its IEEE-754 single- or double-precision floating-point representation: sign bit, biased exponent, mantissa, and raw hex.

How it works

Enter a number, choose single or double precision, and click Analyze.

What does an IEEE 754 analyzer show?

An IEEE 754 analyzer shows exactly how a computer stores a decimal number as a binary floating-point value. It splits the bit pattern into three fields: a sign bit, a biased exponent and a mantissa (the fraction). It also prints the raw hex. This tool does it for 32-bit single precision and 64-bit double precision, the two formats almost every language uses for float and double.

The formats are defined in IEEE 754-2019, the current revision of the standard, where they're called binary32 and binary64. JavaScript's own Number type is binary64 (ECMAScript specification), so the double-precision output is literally what your browser holds in memory.

Field layout

Format Total bits Sign Exponent Fraction Bias
Single (binary32) 32 1 8 23 127
Double (binary64) 64 1 11 52 1023

For a normal number the value is (-1)^sign × 1.fraction × 2^(exponent - bias). The leading 1. isn't stored; it's implied, which buys one free bit of precision.

How to use it

  1. Type a number, for example -6.5.
  2. Choose Double (64-bit) or Single (32-bit) under Precision.
  3. Click Analyze.
  4. Read the four lines: sign, exponent bits with the unbiased exponent (or a zero, subnormal or special label) in brackets, all 23 or 52 mantissa bits, and hex.

Worked example: -6.5

Do it by hand first. 6.5 in binary is 110.1 (4 + 2 + 0.5). Normalise it by moving the point two places left: 1.101 × 2². So:

  • the sign is 1, because the number is negative
  • the true exponent is 2, stored as 2 + 127 = 129 = 10000001 in single precision
  • the fraction is what follows the leading 1: 101, padded with zeros

The analyzer agrees. Single precision prints:

Sign: 1
Exponent: 10000001 (2)
Mantissa: 10100000000000000000000
Hex: 0xc0d00000

Double precision uses the larger bias, 2 + 1023 = 1025:

Sign: 1
Exponent: 10000000001 (2)
Mantissa: 1010000000000000000000000000000000000000000000000000
Hex: 0xc01a000000000000

Why 0.1 + 0.2 isn't 0.3

Try 0.3 and then 0.30000000000000004 (which is what JavaScript gives for 0.1 + 0.2) in double precision. The hex outputs are 0x3fd3333333333333 and 0x3fd3333333333334: one unit apart in the last place. Both started as rounded approximations of decimals that repeat forever in binary, and the rounding errors don't cancel.

Single precision has the same problem with fewer bits. 0.1 becomes 0x3dcccccd, which is really 0.100000001490116119384765625. You can see the same rounding in JavaScript with Math.fround(). Integers run out too: 16777217 in single precision comes back as 0x4b800000, which is 16777216, because 24 bits of significand can't hold it.

Special values

Input Exponent field Fraction Hex (single)
0 all zeros all zeros 0x00000000
-0 all zeros all zeros 0x80000000
1e-45 all zeros ...0001 (subnormal) 0x00000001
Infinity all ones all zeros 0x7f800000
NaN all ones non-zero 0x7fc00000
3.4e39 all ones all zeros overflows to 0x7f800000

The bracket after the exponent bits follows these cases. Zeros print (zero). Subnormals print the minimum exponent the standard gives them, 1 - bias, with a flag: 1e-45 in single precision shows Exponent: 00000000 (-126, subnormal), and 5e-324 in double shows (-1022, subnormal) with a mantissa line ending in a single 1. An all-ones field isn't an exponent, so Infinity, -Infinity and 3.4e39 (which overflows in single precision) show (special: Infinity), and NaN shows (special: NaN). The sign line tells +Infinity from -Infinity.

What it doesn't do

It doesn't convert a hex bit pattern back into a number, doesn't support half precision (16-bit) or 128-bit formats, and doesn't show the exact decimal value of the stored float. Single-precision results come from first parsing your input as a double and then rounding to the nearest 32-bit float, which is the same thing Math.fround does.

Related tools

  • Decimal to binary handles the integer part when you're normalising by hand.
  • Hex to binary expands a single-precision Hex line into its 32 bits; split a double's 16 hex digits into two halves first, since that tool stops at 53 bits.
  • Binary to decimal turns the exponent field back into its stored value.
  • The JavaScript lessons include a lesson on numbers that covers the 0.1 + 0.2 surprise from the coding side.

Last updated

Frequently asked questions

What are the sign, exponent and mantissa in IEEE 754?
The sign bit is 0 for positive and 1 for negative. The exponent field stores a power of two plus a bias (127 in single precision, 1023 in double). The mantissa, or fraction, stores the digits after the leading 1 of the normalised binary number. Value = (-1)^sign × 1.mantissa × 2^(exponent - bias).
Why does 0.1 not convert exactly?
0.1 has no finite binary representation, so it repeats forever (0.000110011001100...) and has to be rounded to fit. In double precision the stored value is 0x3fb999999999999a, about 0.1000000000000000055511151; in single precision it's 0x3dcccccd, about 0.100000001490116.
What does the number in brackets after the exponent mean?
For a normal number it's the true exponent, the stored field minus the bias, so 1 shows (0) and -6.5 shows (2). An all-zeros field shows (zero) for ±0, or (-126, subnormal) in single precision and (-1022, subnormal) in double, because subnormals use the minimum exponent 1 - bias. An all-ones field isn't an exponent at all, so it shows (special: Infinity) or (special: NaN).
What can I type in?
Anything JavaScript's Number() accepts: 6.5, -0.001, 1e-45, .5, Infinity, -Infinity, NaN (any case), and even 0x10 or 0b101, which are read as whole numbers. Commas and words are rejected with "Enter a valid number." Infinity must be spelled with a capital I.
Is anything sent to a server?
No. The bit layout is computed in your browser with a DataView, and nothing leaves the page.