IEEE 754 Floating-Point Converter
See exactly how a number is stored in binary floating point — every bit, every digit.
Convert
Decimal, scientific (6.02e23), a fraction (1/3), a C hex float (0x1.8p3), inf, nan, nan(0x1f) or snan.
Hex (3DCCCCCD, 0x3dcc_cccd) or binary starting with 0b. Shorter hex is padded with leading zeros.
In every format
Choose a format to see its bits and details below.
Double precision (binary64)
Try one operation (why 0.1 + 0.2 ≠ 0.3)
Format facts
About the IEEE 754 Floating-Point Converter
Type a number and see how it is stored as an IEEE 754 binary floating-point value in half (binary16), bfloat16, single (binary32), double (binary64) and quadruple (binary128) precision: the sign, exponent and fraction bits, the hex pattern, and the exact stored value with every digit, so you can see the rounding error instead of guessing it. Or enter a bit pattern such as 3DCCCCCD and read the number back, including subnormals, signed zeros, infinities and NaNs with their payloads.
The page works with exact rational arithmetic: a decimal like 0.1 is rounded once, straight to the target format, using any of the five IEEE rounding directions — never through a JavaScript number first. The arithmetic panel performs one correctly rounded IEEE operation, which shows step by step why 0.1 + 0.2 is 0.30000000000000004 in double precision.
How to use it
- Under Number → bits, type a number: a decimal (
0.1), scientific notation (6.02e23), a fraction (1/3), a C hex float (0x1.8p3),inf,nan,nan(0x1f)orsnan. Choose the rounding direction if you need one other than the default. - Read the hex pattern, the shortest decimal that converts back to the same bits and the rounding error for every format. Choose a format to see its details.
- In the bit grid, click a bit (or move with the arrow keys and press Space) to flip it; the page switches to Bits → number and decodes the new pattern. You can also type a pattern in hex or as
0b…binary there. - Copy the hex, binary, exact decimal or C hex-float form. Use the arithmetic panel to try one operation (+ − × ÷) in any format and compare the result with a value you expect.
Examples
0.1
0x3FB999999999999A = 0.1000000000000000055511151231257827021181583404541015625
One tenth is a repeating fraction in binary (0.000110011001100…), so it is rounded to the nearest of the 2⁵³ significands available at that exponent. The error is about 5.6 × 10⁻¹⁸.
16777217 (single)
0x4B800000 = 16777216
Single precision has a 24-bit significand, so above 2²⁴ = 16,777,216 only even integers exist; 16,777,217 is a tie and rounds to the even neighbour.
65520 (half)
0x7C00 = +∞
The largest half-precision number is 65504. 65520 lies exactly halfway to the next step (65536, which is out of range), and round-to-nearest-even overflows it to infinity.
0.1 + 0.2, compared with 0.3
Sum 0x3FD3333333333334 (0.30000000000000004) ≠ 0.3 stored as 0x3FD3333333333333 — 1 ULP apart
Common uses
- Understanding floating-point rounding errors, and explaining them to students or in code reviews.
- Decoding a float or double from a hex dump, a network packet, a register or a binary file.
- Checking the bit patterns and limits of half and bfloat16 values used in GPU and machine-learning code.
- Producing exact test values for parsers and printers (shortest round-trip decimals, C hex floats, signed zeros, subnormals, NaN payloads).
How a binary floating-point number is stored
IEEE Std 754-2019 (clause 3.4) encodes a binary floating-point number in three fields: a sign bit s, a biased exponent E of w bits and a trailing significand (fraction) T of t bits. With bias = 2^(w−1) − 1:
- If 0 < E < all ones, the number is normal: (−1)^s × 1.T × 2^(E − bias). The leading 1 is implicit, so the precision is p = t + 1 bits.
- If E = 0 and T ≠ 0, the number is subnormal: (−1)^s × 0.T × 2^(1 − bias). These fill the gap between zero and the smallest normal number (gradual underflow).
- If E = 0 and T = 0, it is ±0; if E is all ones, it is ±∞ (T = 0) or NaN (T ≠ 0).
Half precision has w = 5, t = 10 (bias 15); single w = 8, t = 23 (bias 127); double w = 11, t = 52 (bias 1023); quad w = 15, t = 112 (bias 16383). The format facts panel lists the range and precision each one gives.
Why 0.1 + 0.2 ≠ 0.3
Most decimal fractions have no finite binary expansion, so each one is rounded when stored. In double precision 0.1 becomes 0.1000000000000000055511151231257827…, 0.2 becomes 0.2000000000000000111022302462515654…, and 0.3 becomes 0.2999999999999999888977697537484345…. The exact sum of the first two is 0.3000000000000000166533453693773481…, and IEEE addition rounds that to the nearest double, 0.3000000000000000444089209850062616… — one step (one ULP) above the double nearest to 0.3. Nothing is broken: both results are correctly rounded, they just come from different roundings. Compare floating-point results with a tolerance, or use decimal or integer arithmetic (for money, count cents) when exact decimal results matter.
Rounding directions
IEEE 754-2019 (clause 4.3) defines roundTiesToEven — the default for binary formats, used by virtually all hardware and languages — plus roundTiesToAway, roundTowardZero, roundTowardPositive and roundTowardNegative. Ties-to-even picks the neighbour whose last significand bit is 0, so ties do not drift up or down on average. When a result is too large, the two nearest modes give ±∞, toward-zero gives the largest finite number, and the directed modes give ∞ on one side and the largest finite number on the other (clause 7.4).
NaNs, payloads and signed zeros
A NaN has an all-ones exponent and a non-zero fraction. IEEE 754-2019 (clause 6.2.1) says the first fraction bit should be 1 for a quiet NaN and 0 for a signalling NaN; the remaining bits are the payload, which programs can use to carry diagnostic information. This page shows and preserves the payload; arithmetic here returns the default quiet NaN (payload 0), while real hardware may pass an input’s payload through. −0 and +0 compare equal but behave differently: 1/−0 is −∞, and a sum of opposite numbers is +0 except when rounding toward −∞.
About bfloat16
bfloat16 is not one of the IEEE 754 formats: it is the upper half of a binary32 value — the same sign and 8-bit exponent, with a 7-bit fraction — popular in machine learning because it keeps single precision’s range. The page encodes it with the IEEE rules (subnormals, ±∞, NaN) and rounds the exact value to nearest, ties to even. Some software and hardware instead convert a single-precision value by simply dropping its lower 16 bits; that is rounding toward zero from single precision, so for a decimal input it can differ in the last bit from the toward-zero setting here, which rounds the exact value.
Limitations
- Only binary interchange formats are covered: not the x87 80-bit extended format, IEEE decimal formats (decimal32/64/128), IBM hexadecimal floating point or the 8-bit FP8 formats.
- The arithmetic panel performs one operation at a time (+, −, ×, ÷) and does not evaluate expressions.
- Numbers whose decimal exponent is beyond ±5,100 are outside every format here; they convert to ±∞, ±0 or the largest or smallest value according to the rounding direction, and their rounding error is not printed digit by digit.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Why can’t 0.1 be stored exactly?
A binary fraction can only represent sums of powers of two. One tenth in binary is 0.0001100110011… with the pattern repeating forever, so it has to be cut off and rounded. Fractions like 0.5, 0.25 or 0.375 are exact because their denominators are powers of two.
What is the difference between single and double precision?
Single precision (float, 32 bits) has a 24-bit significand — about 7 significant decimal digits — and reaches about 3.4 × 10³⁸. Double precision (double, 64 bits) has a 53-bit significand — about 15–17 digits — and reaches about 1.8 × 10³⁰⁸. JavaScript numbers and Python floats are doubles.
What is a subnormal (denormal) number?
A value smaller in magnitude than the smallest normal number, stored with an exponent field of 0 and no implicit leading 1. Subnormals lose precision gradually instead of jumping straight to zero; the smallest double subnormal is 2⁻¹⁰⁷⁴ ≈ 4.94 × 10⁻³²⁴. Some hardware modes (“flush to zero”) treat them as 0 for speed.
Why does JavaScript print 0.30000000000000004?
JavaScript prints the shortest decimal that converts back to exactly the same double. For the double nearest to 0.3 that is “0.3”; the result of 0.1 + 0.2 is the next double up, and the shortest decimal that identifies it needs 17 digits. The Shortest round-trip line on this page uses the same rule.
Is −0 really different from 0?
They have different bit patterns (the sign bit) and compare as equal. The difference shows up in a few operations: 1 / −0 is −∞, Math.atan2 and copysign see the sign, and some formatting functions print “-0”.
What does “round to nearest, ties to even” mean?
The stored value is the representable number closest to the exact one. When the exact value lies exactly halfway between two, the one whose last significand bit is 0 (the “even” one) is chosen. That is why 16,777,217 becomes 16,777,216 in single precision while 16,777,219 becomes 16,777,220.