CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

IEEE 754 Float Converter (32 & 64-bit)

See how computers store numbers: convert between decimal, hex, binary, and the sign/exponent/mantissa bit fields of IEEE 754 floats and doubles, with subnormal, infinity, and NaN detection.

Overview

Shows how computers actually store decimal numbers: type any value and see its IEEE 754 representation as a 32-bit float or 64-bit double - the full binary pattern with sign, exponent, and mantissa fields colour-coded, plus hex, unbiased exponent, and classification (normal, subnormal, infinity, NaN). It also runs in reverse: paste a hex or binary bit pattern and read back the decimal value it represents.

How It Works

Choose Float32 or Float64, then type a decimal number, a 0x-prefixed hex bit pattern, or a 0b-prefixed binary bit pattern. Everything recomputes live: the binary pattern (with the sign, exponent, and mantissa segments in different colours and restated in text for accessibility), the field breakdown, and the classification. Click any field to copy it.

Step-by-Step Usage Guide

  1. Pick the width: Float32 for C floats and WebGL, Float64 for JavaScript numbers and most languages' double.
  2. Enter a decimal value, or a 0x/0b bit pattern to decode memory you have seen somewhere.
  3. Read the field breakdown - sign, raw and unbiased exponent, mantissa fraction.
  4. Use the kind line to check for subnormals, infinity, or NaN rather than eyeballing bit patterns.

Technical Specifications & Standards

IEEE 754 stores a number as (-1)^sign x 1.fraction x 2^(exponent - bias), with bias 127 for float32 and 1023 for float64. That layout explains every famous floating-point surprise: 0.1 is not exactly representable because its binary fraction repeats forever and gets truncated, which is why 0.1 + 0.2 !== 0.3 in JavaScript; the largest exact integer in a double is 2^53 because the fraction field only holds 52 stored bits plus the implicit leading 1. The tool distinguishes the edge cases the spec defines: exponent all-zeros with a nonzero fraction is subnormal (denormal) - the gradual underflow region below the smallest normal value, about 1.18e-38 for float32; exponent all-ones means infinity or NaN depending on the fraction. Hex input is read as the raw bit pattern rather than as an integer value, which is the operation you need when inspecting a memory dump or a wire format. Conversion uses the platform's DataView, so results are bit-exact with what your CPU and every other IEEE 754 system produce.

Targeted Use Cases

  • Understanding why 0.1 + 0.2 is 0.30000000000000004 - look at the mantissa truncation.
  • Decoding a float from a binary file, sensor packet, or memory dump given as hex.
  • Debugging precision loss between a 32-bit float pipeline (graphics, game engines) and 64-bit code.
  • Teaching or learning computer architecture: every field of the format is visible and live.

Notes & Gotchas

  • Remember float32 has about 7 significant decimal digits and float64 about 15 - do not expect more precision than the width provides.
  • When comparing hex patterns across tools, match the width first; the same decimal has completely different patterns at 32 and 64 bits.
  • Subnormal values trade precision for range; if your readings near zero look quantised, that is why.
  • Never compare floats with === in code; compare against an epsilon - this tool shows exactly why two 'equal' values can differ in the last mantissa bit.

Frequently Asked Questions

Why does 0.1 show a long repeating mantissa?

0.1 in binary is 0.0001100110011... repeating forever. IEEE 754 truncates at the fraction field's width (23 bits for float32, 52 for float64), so the stored value is the closest representable number - slightly above or below 0.1, and the printout shows you exactly which.

What is the difference between the raw and unbiased exponent?

The exponent is stored with a bias (127 or 1023) so it can represent small and large magnitudes without a sign field. The raw field is what sits in the bits; the unbiased value is what the formula actually uses.

Is hex input the number 0x3f800000, or the float whose bits are that?

The bits. 0x3f800000 as an integer is about 1.07 billion, but as a float32 bit pattern it is exactly 1.0. This tool always interprets hex as the bit pattern, which is what memory inspection needs.

Why does JavaScript only show one number type if doubles and floats differ?

JavaScript's Number is IEEE 754 float64. But TypedArrays (Float32Array), WebGL, WASM, and binary file formats all use float32, so the width distinction matters the moment you touch binary data.