Skip to content

IEEE 754 Floating Point Converter

Encode decimal values to IEEE 754 binary32 or binary64 fields and decode exact bit or hexadecimal patterns back to browser numbers.

Privacy: your files never leave your device. All processing happens locally in your browser.

How to use

  1. 1.Choose decimal-to-bits or bits-or-hex-to-decimal and select binary32 or binary64.
  2. 2.Enter one value, convert, and inspect the stored value plus sign, exponent, fraction, class, bits, and hex.
  3. 3.Copy the hex and verify precision and byte order against the actual consumer before using it in a protocol or file.

About IEEE 754 Floating Point Converter

IEEE 754 Floating Point Converter exposes the bit pattern a browser stores for binary32 single precision or binary64 double precision. Choose decimal-to-bits or bits-to-decimal, select a format, enter a value, and inspect the stored number, hexadecimal representation, sign, exponent, fraction, classification, and unbiased exponent. All conversion happens with the browser's DataView API.

Decimal input accepts ordinary base-ten notation with an optional sign, fraction, and decimal exponent. It also accepts Infinity, -Infinity, and NaN. Hexadecimal numeric literals, expressions, commas, units, and locale-specific decimal separators are rejected. This keeps number parsing explicit and avoids JavaScript coercions such as treating an empty string as zero or accepting a hexadecimal token as a decimal value.

For binary32, the display splits 32 bits into one sign bit, eight exponent bits, and 23 fraction bits. For binary64, it splits 64 bits into one sign bit, 11 exponent bits, and 52 fraction bits. Hexadecimal is shown most-significant byte first, with exactly eight digits for binary32 or 16 digits for binary64. The copy action copies those hex digits without the 0x label.

Encoding writes the JavaScript Number through DataView.setFloat32 or DataView.setFloat64 in big-endian byte order, then reads the stored value back. binary32 therefore shows the rounding that occurs when a binary64 JavaScript input is narrowed to single precision. binary64 reflects the browser's double-precision interchange value, not the original decimal spelling or arbitrary-precision decimal arithmetic.

Decoding accepts exactly 32 or 64 binary digits, or exactly eight or 16 hexadecimal digits, with an optional 0x prefix for hex. It writes those bits into an ArrayBuffer and reads the matching float. This path preserves the entered sign, exponent, and fraction fields in the display. JavaScript still exposes all NaN values as NaN, so distinct NaN payloads cannot be distinguished through the numeric value alone even though the entered bits remain visible.

An all-zero exponent with a zero fraction is classified as zero; with a nonzero fraction it is subnormal. A nonzero exponent below the all-ones pattern is normal. An all-ones exponent with zero fraction is infinity, and with a nonzero fraction is NaN. The unbiased exponent is exponent minus 127 for normal binary32 or minus 1023 for normal binary64. Subnormals use one minus the bias.

Positive and negative zero compare equal in most arithmetic, but they have different sign bits and can produce different results in operations such as reciprocals. This page preserves -0 when entered or decoded. Infinity and NaN are special values, not ordinary numbers with a finite unbiased exponent. The tool reports their classification instead of inventing a misleading exponent.

Decimal-to-binary conversion is not a proof that a decimal value is exact. Many decimal fractions, including 0.1, require an infinite binary expansion and round to the nearest representable value. Large integers can lose unit precision in binary64, and binary32 loses precision much sooner. Use decimal or integer libraries when a domain requires exact money, identifiers, or arbitrary precision.

Eight external fixtures cover binary32 one, negative zero, positive infinity, maximum finite, minimum positive subnormal, and binary64 one, negative zero, and pi. Additional tests decode subnormal, infinity, NaN, and binary input boundaries. Compare the bit pattern with the language, file format, network protocol, or hardware specification that will consume it, because byte order and precision are part of that contract.

Methodology & sources

Uses big-endian DataView float reads and writes, extracts fixed binary32 or binary64 sign/exponent/fraction widths, classifies zero/subnormal/normal/infinity/NaN from exponent and fraction patterns, and reads back the rounded stored value without hand-approximating conversion.

Frequently asked questions

Why does binary32 change my decimal value?
JavaScript first parses a double-precision Number, then DataView rounds it to the nearest representable binary32 value. The stored value shows that narrowing.
Why are there two zeros?
IEEE 754 has positive and negative zero with different sign bits. They compare equal in ordinary comparisons but can behave differently in some operations.
Does decoding preserve a NaN payload?
The entered bits remain visible, but ECMAScript exposes NaN values without guaranteeing that distinct payloads remain distinguishable as Numbers.

Developer Tools guides

View all