IEEE 754 Float/Double Converter – Decimal ↔ Hex ↔ Binary Bit Pattern

Convert between decimal, hexadecimal, and IEEE 754 binary bit patterns for 32-bit float and 64-bit double. Visualize sign, exponent, and mantissa fields. Debug firmware register dumps, NaN/Inf values, and floating-point encoding.

What is IEEE 754?

IEEE 754 is the international standard for binary floating-point arithmetic, first published in 1985 by the Institute of Electrical and Electronics Engineers. It defines precisely how computers store and compute with real numbers at the hardware level — used by every CPU, GPU, DSP, and microcontroller manufactured in the last four decades. Before IEEE 754, different manufacturers implemented incompatible floating-point formats, making numeric code impossible to port reliably. The standard resolved this by specifying two primary formats: 32-bit single precision (float) and 64-bit double precision (double), along with rules for rounding, infinity, zero, and the special Not-a-Number (NaN) encoding. A 2008 revision added 16-bit half precision and 128-bit quad precision, but float and double remain by far the most widely used.

Every IEEE 754 value — whether a finite number, zero, infinity, or NaN — is encoded as exactly three fields packed into 32 or 64 contiguous bits: a sign bit (0 = positive, 1 = negative), a biased exponent (8 bits for float, 11 bits for double), and a fractional mantissa (23 bits for float, 52 bits for double). Understanding this raw bit pattern is essential for embedded firmware development, decoding hardware register dumps, diagnosing floating-point precision errors, and verifying numeric code across different platforms and compilers. This tool lets you explore any float or double by entering it as a decimal, hexadecimal, octal, or binary value and shows you the exact IEEE 754 bit structure in real time with a color-coded bit visualization.

How to Use This Tool

  1. Select Precision — Choose 32-bit Float or 64-bit Double using the tabs at the top of the converter. The bit layout, decoded field panel, and input placeholders all update to reflect the selected precision. Your choice is saved automatically to browser localStorage.
  2. Enter a Value in Any Field — All four fields (Decimal, Hex, Octal, Binary) accept input, and any one of them can be the source of truth. Decimal: type any floating-point number (e.g. 3.14, -273.15, 1e-10) or a special value (NaN, inf, -inf, -0). Hex: paste the raw bit pattern (e.g. 0x4048F5C3 for float 3.14; formats 0x, x, \x, or plain accepted). Octal: enter the octal bit pattern (e.g. 0o10022172703; formats 0o, o, 0-prefix, or plain). Binary: enter the 32- or 64-character binary string (formats 0b, b, or plain).
  3. Read the Color-Coded Bit Layout — The visualization at the top of the converter shows every individual bit in its IEEE 754 field: red for the sign bit, blue for all exponent bits, and green for all mantissa bits. Hover over any bit group to see its field label. The binary string displayed corresponds exactly to the field widths of the selected precision.
  4. Inspect the Decoded Field Panel — Below the bit visualization, the decoded panel shows: Sign Bit (positive or negative), Value Class (Normal, Denormalized, NaN, Infinity, Zero), Biased Exponent (the raw field value in decimal, hex, and binary), Actual Exponent (biased exponent minus 127 for float or 1023 for double), Mantissa raw bits (hex and binary), and Mantissa value (the significand fraction, with the implicit leading 1 shown for normal numbers). Click any decoded field to copy its value.
  5. Copy Results — Click the copy icon next to any of the four input/output fields to copy the value to your clipboard. The copy button in the Bit Layout section copies the full binary string. All copy actions are available even while editing another field.

32-bit Float vs 64-bit Double: Format Breakdown

The table below compares the two primary IEEE 754 formats supported by this tool. The number of mantissa bits directly determines decimal precision; the number of exponent bits determines the representable range.

FormatTotal BitsSignExponent BitsMantissa BitsBias~Decimal DigitsNormal Range
float (f32)321823127~7~1.18e-38 to ~3.40e+38
double (f64)64111521023~15-17~2.23e-308 to ~1.80e+308

The machine epsilon — the smallest value ε such that 1.0 + ε ≠ 1.0 — is ~1.19e-7 for float and ~2.22e-16 for double. Use float when memory or bandwidth is tight (e.g. GPU buffers, Modbus registers, neural network weights). Use double for scientific computing, financial calculations, and any context where accumulated rounding error matters.

Understanding the Three Bit Fields

Sign Bit (bit 31 for float, bit 63 for double)

The most significant bit of every IEEE 754 value is the sign bit. A value of 0 means the number is positive (or positive zero, positive infinity). A value of 1 means the number is negative. The sign bit is independent of the magnitude — the same absolute value with sign=0 and sign=1 gives +x and -x. This means IEEE 754 has two distinct encodings for zero: +0 (0x00000000) and -0 (0x80000000). Both compare equal under ==, but they are bit-different and can be distinguished by inspecting the sign bit directly.

Sign bit examples (32-bit float):

  • 3.14 → bit 31 = 0 (positive) → hex 0x4048F5C3
  • -3.14 → bit 31 = 1 (negative) → hex 0xC048F5C3
  • +0.0 → bit 31 = 0 → hex 0x00000000
  • -0.0 → bit 31 = 1 → hex 0x80000000

Biased Exponent (bits 30-23 for float, bits 62-52 for double)

The exponent field encodes the power of 2 that scales the mantissa, but it stores the exponent plus a fixed bias (127 for float, 1023 for double) as an unsigned integer. The bias allows the exponent field to be compared and sorted as unsigned integers, simplifying hardware comparisons. To find the actual (unbiased) exponent: subtract 127 from the 8-bit field value (float), or subtract 1023 from the 11-bit field value (double). Two exponent field values are reserved: all zeros (0x00) encodes zero and subnormals; all ones (0xFF for float, 0x7FF for double) encodes infinity and NaN.

Exponent field examples (32-bit float):

  • 3.14 → biased exp field = 128 (0x80, 0b10000000) → actual exp = 128 - 127 = 1 → value ≈ 1.57 × 2¹
  • 1.0 → biased exp field = 127 (0x7F, 0b01111111) → actual exp = 0 → value = 1.0 × 2⁰
  • 0.5 → biased exp field = 126 (0x7E) → actual exp = -1 → value = 1.0 × 2⁻¹
  • Infinity → biased exp field = 255 (0xFF) — reserved, mantissa = 0
  • Denormal → biased exp field = 0 (0x00) — reserved, actual exp fixed at -126

Mantissa / Significand (bits 22-0 for float, bits 51-0 for double)

The mantissa (also called the significand or fraction field) stores the fractional part of the number. For normal (non-subnormal) numbers, an implicit leading 1 bit is prepended to the mantissa, giving a significand in the range [1.0, 2.0). This means a 23-bit mantissa field actually provides 24 bits of precision (the leading 1 is free). The full value of a normal IEEE 754 float is: (-1)^sign × 2^(exponent−127) × (1 + mantissa/2²³). For subnormal numbers the leading bit is 0 (explicit), the exponent is fixed at 2^(−126), and the significand is in [0.0, 1.0).

Mantissa field examples (32-bit float for 3.14):

  • Hex: 0x4048F5C3
  • Binary: 0 10000000 10010001111010111000011
  • Mantissa bits: 10010001111010111000011 (23 bits)
  • Mantissa value: 1 + 0b.10010001111010111000011 = 1.5700000524...
  • Full value: 1.5700000524... × 2¹ = 3.1400001049...

Worked Example: 3.14 as IEEE 754 32-bit Float

This step-by-step conversion shows exactly how the decimal value 3.14 maps to the IEEE 754 bit pattern 0x4048F5C3.

Step 1 — Convert 3.14 to binary:

  • Integer part: 3 = 0b11
  • Fractional part: 0.14 → 0.0010001111010111000010100... (repeating)
  • 3.14 in binary: 11.0010001111010111000010100...

Step 2 — Normalize to 1.xxx × 2^n form:

  • Shift binary point left by 1: 1.10010001111010111000010100... × 2¹
  • Actual exponent = 1

Step 3 — Sign bit:

  • 3.14 is positive → sign bit = 0

Step 4 — Biased exponent:

  • Biased exponent = actual exponent + bias = 1 + 127 = 128
  • 128 in binary (8 bits): 10000000

Step 5 — Mantissa (23 bits, drop the leading 1):

  • Significand: 1.10010001111010111000011 (rounded to 23 fractional bits)
  • Mantissa field: 10010001111010111000011

Step 6 — Assemble the 32-bit pattern:

  • Full binary: 0 10000000 10010001111010111000011
  • Hex: 0x4048F5C3

Verification: Enter 3.14 in the Decimal field above — the tool outputs 0x4048F5C3.

Inspecting Float Bits in Code

This tool provides instant conversion, but you may also need to inspect float bits programmatically in your own code. The following examples show the standard technique for each major language — all produce the same bit pattern as this tool.

C / C++ — memcpy type-pun (safe, no undefined behavior)

#include <stdint.h>
#include <string.h>
#include <stdio.h>

int main(void) {
    float f = 3.14f;
    uint32_t bits;
    memcpy(&bits, &f, sizeof(f));
    printf("0x%08X\n", bits);  // 0x4048F5C3

    // Decode back
    float decoded;
    memcpy(&decoded, &bits, sizeof(bits));
    printf("%f\n", decoded);   // 3.140000
    return 0;
}
// For double: use uint64_t and double instead

Python — struct.pack / struct.unpack

import struct

# float (32-bit) to hex
bits = struct.unpack('>I', struct.pack('>f', 3.14))[0]
print(f"0x{bits:08X}")   # 0x4048F5C3

# hex to float
val = struct.unpack('>f', struct.pack('>I', 0x4048F5C3))[0]
print(val)                # 3.140000104904175

# double (64-bit) to hex
bits64 = struct.unpack('>Q', struct.pack('>d', 3.14))[0]
print(f"0x{bits64:016X}") # 0x40091EB851EB851F

Rust — f32::to_bits() / f32::from_bits()

fn main() {
    let f: f32 = 3.14;
    let bits: u32 = f.to_bits();
    println!("0x{:08X}", bits);  // 0x4048F5C3

    let decoded = f32::from_bits(bits);
    println!("{}", decoded);     // 3.14

    // double
    let d: f64 = 3.14;
    let bits64: u64 = d.to_bits();
    println!("0x{:016X}", bits64); // 0x40091EB851EB851F
}

JavaScript — DataView (handles endianness)

// 32-bit float to hex
const buf = new ArrayBuffer(4);
const view = new DataView(buf);
view.setFloat32(0, 3.14, false); // false = big-endian
const bits = view.getUint32(0, false);
console.log('0x' + bits.toString(16).toUpperCase()); // 0x4048F5C3

// hex to float
view.setUint32(0, 0x4048F5C3, false);
console.log(view.getFloat32(0, false)); // 3.140000104904175

// 64-bit double: use setFloat64 / getFloat64 + BigInt

IEEE 754 Arithmetic: Rounding and Precision

Why 0.1 + 0.2 does not equal 0.3

The decimal fractions 0.1 and 0.2 are infinite repeating fractions in binary, just as 1/3 repeats in decimal. When stored as IEEE 754 float or double, each is rounded to the nearest representable bit pattern. Adding two independently rounded values produces a result that is also rounded — and that result may differ from the rounded representation of the true sum. This is not a bug in the CPU or language; it is the mathematically correct IEEE 754 result. The only fix is to use decimal arithmetic libraries (Python's decimal module, Java's BigDecimal) or integer scaling (storing prices in cents rather than dollars).

0.1 in IEEE 754 (32-bit float):

  • Binary: 0.000110011001100110011001101... (infinitely repeating)
  • Rounded to 24 significant bits: 0.000110011001100110011010
  • Actual stored value: 0.100000001490116...
  • Hex: 0x3DCCCCCD

0.2 in IEEE 754 (32-bit float):

  • Actual stored value: 0.200000002980232...
  • Hex: 0x3E4CCCCD

0.1 + 0.2 = 0.300000011920929 (not 0.3)

0.3 stored as float: 0.300000011920929... (hex 0x3E99999A)

Rounding Modes

IEEE 754 defines five rounding modes. The default — and by far the most commonly used — is Round to Nearest Even (also called banker's rounding). When a value falls exactly halfway between two representable numbers, it rounds to the one whose least significant bit is 0 (even). This minimizes cumulative rounding bias over long computations. The four alternatives are: Round to Nearest Away (ties away from zero), Round toward +Infinity (ceiling), Round toward -Infinity (floor), and Round toward Zero (truncation). Most languages and CPUs use Round to Nearest Even by default; changing the rounding mode requires modifying the floating-point control register (FPCSR on ARM, MXCSR on x86).

Catastrophic Cancellation

Catastrophic cancellation occurs when two nearly equal floating-point numbers are subtracted, causing most significant bits to cancel and leaving only the low-order (least precise) bits in the result. For example, computing (1000000.1 - 1000000.0) in float loses precision because both operands are represented with the same exponent and only 7 significant digits are available. The result has far fewer correct digits than either input. The fix is to restructure the computation to avoid subtracting nearly equal values — for example, using compensated summation (Kahan summation) or a numerically stable algorithm.

Common Use Cases

  • Firmware and Embedded Register Debugging: When a sensor, ADC, DSP, or FPGA returns a 32-bit hex register value that represents a float, paste it into the Hex field to instantly see the decoded decimal value and full bit layout. For example, a temperature sensor returning 0x42280000 decodes to 42.0. A motor controller showing 0xBF800000 decodes to -1.0. This eliminates the need to calculate the bit fields by hand from a datasheet.
  • NaN and Infinity Detection and Diagnosis: When a computation produces unexpected results, entering the hex bit pattern reveals whether the value is a Quiet NaN, Signaling NaN, +Infinity, or -Infinity, and shows the NaN payload in the mantissa field. For example, 0x7FC00000 is the canonical Quiet NaN produced by most C runtimes for 0.0/0.0, while 0x7F800001 is a Signaling NaN sometimes used as a trap value.
  • Cross-Platform Numeric Portability: Verify that a float serialized on a big-endian PowerPC server produces the same bit pattern on a little-endian ARM MCU after byte-swapping. Enter the value in decimal to get the expected hex pattern, then use the Endian Converter to swap bytes and verify.
  • Modbus and CAN Bus Float Decoding: Industrial protocols such as Modbus RTU, CAN Open, and PROFIBUS often transmit IEEE 754 floats packed into one or two 16-bit registers. Paste the concatenated register hex into this tool to decode the sensor reading, setpoint, or control variable without manual bit manipulation.
  • Learning and Teaching Floating-Point Internals: Step through instructive examples like 0.1, 1.0/3.0, 16777216.0, and 16777217.0 (the smallest float that rounds to 16777216) to see exactly how precision is lost at the bit level. Compare the mantissa fields of adjacent float values to understand ULP (Units in the Last Place) distance.
  • Compiler and Runtime Verification: Confirm that a C compiler, embedded toolchain, or hardware FPU computes the same bit pattern as the IEEE 754 standard requires. Enter the expected hex value here, read the decimal, and compare against your hardware output to detect FPU bugs, mismatched ABI float formats, or unexpected flush-to-zero modes on embedded processors.

IEEE 754 Special Values

The IEEE 754 standard reserves specific bit patterns for special values. The exponent field values of all-zeros and all-ones are never used for normal finite numbers — they encode zero, subnormals, infinity, and NaN. The table below shows the 32-bit float encoding for each special category.

ValueSignExponent (8-bit)Mantissa (23-bit)Hex (32-bit)Notes
+Zero00000000000000…00x00000000Positive zero — default uninitialized
-Zero10000000000000…00x80000000Negative zero; -0 == +0 is true
+Infinity01111111100000…00x7F800000Positive overflow, 1.0/0.0
-Infinity11111111100000…00xFF800000Negative overflow, -1.0/0.0
Quiet NaN0111111111xxxxxx…0x7FC00000Silent propagation: 0/0, sqrt(-1)
Signaling NaN0111111110xxxxxx1+0x7F800001Raises exception when used in arithmetic
Subnormal / Denormal0/100000000non-zero0x00000001…Gradual underflow, no implicit leading 1
Smallest Normal00000000100000…00x00800000≈ 1.175494e-38
Largest Normal01111111011111…10x7F7FFFFF≈ 3.402823e+38 (FLT_MAX)
Smallest Subnormal00000000000000…10x00000001≈ 1.401298e-45 (FLT_TRUE_MIN)

Frequently Asked Questions — IEEE 754 Float Converter

What is the implicit leading 1 in the mantissa?

For all normal (non-subnormal, non-zero) IEEE 754 values, the significand is always in the range [1.0, 2.0). This means the leading binary digit is always 1 — so it does not need to be stored explicitly in the mantissa field. IEEE 754 takes advantage of this by leaving the leading 1 implicit, giving a 23-bit mantissa field 24 bits of effective precision (float) and a 52-bit field 53 bits of effective precision (double). Only subnormal numbers, which have an exponent field of all zeros, use an explicit leading 0 — and this is why the smallest subnormal has lower precision than a normal number.

Why do float comparisons sometimes fail in code?

Because most decimal fractions cannot be exactly represented in binary floating-point, two values that appear equal in decimal may have different bit patterns after rounding. The standard workaround is to compare using an epsilon tolerance: |a - b| < epsilon where epsilon is chosen based on the expected magnitude. For example, |a - b| < 1e-6f for most engineering use cases with float. The machine epsilon for float (~1.19e-7) represents the smallest difference such that 1.0f + epsilon != 1.0f. Never use == to compare float or double values unless you are specifically comparing against exact special values or bit-identical computed results.

What is catastrophic cancellation?

Catastrophic cancellation occurs when two nearly equal floating-point numbers are subtracted, causing most significant bits to cancel and leaving only the imprecise low-order bits in the result. For example, computing sin(x) - sin(y) when x and y are close will lose most significant digits. The fix is to use numerically stable alternatives — for the sine example, use 2 * cos((x+y)/2) * sin((x-y)/2) instead. Inspect the mantissa fields of both operands in this tool to see when they share many leading bits and cancellation risk is high.

How do I check for NaN or Infinity in code?

In C: use isnan(x) and isinf(x) from <math.h>. In C++: use std::isnan and std::isinf from <cmath>. In Rust: f32::is_nan() and f32::is_infinite() on the value. In Python: math.isnan(x) and math.isinf(x) from import math. In JavaScript: Number.isNaN(x) (note: not the global isNaN() which coerces strings) and !isFinite(x). Never compare a float against float.NaN using == — NaN is not equal to itself by definition (NaN != NaN is always true).

What is the machine epsilon and why does it matter?

The machine epsilon (often written ε or eps) is the smallest positive floating-point number such that 1.0 + ε is not equal to 1.0 in floating-point arithmetic. For 32-bit float it is 2^(-23) ≈ 1.1920929e-7. For 64-bit double it is 2^(-52) ≈ 2.2204460e-16. Machine epsilon quantifies the relative rounding error — any float computation has a relative error of at most ε/2 per operation (assuming round-to-nearest). It is the basis for choosing epsilon in approximate comparisons: use |a - b| <= max(|a|, |b|) * eps * n for an operation count of n. Enter 1.1920929e-7 in the Decimal field to see the float machine epsilon's bit pattern.

What is the difference between Signaling NaN and Quiet NaN?

Both types have all exponent bits set to 1 and a non-zero mantissa. The most significant mantissa bit distinguishes them: Quiet NaN (QNaN) has this bit = 1 (e.g. 0x7FC00000 for 32-bit), and propagates silently through all arithmetic operations — computing qnan + 1.0f simply returns another QNaN. Signaling NaN (SNaN) has this bit = 0 with at least one other mantissa bit set (e.g. 0x7F800001), and on hardware that supports it, any arithmetic operation on an SNaN raises an IEEE 754 Invalid Operation floating-point exception. SNaNs are used as sentinel values to detect uninitialized floating-point variables and in debugging tools that need to trap on NaN propagation. Most production code produces QNaN.

When should I use float instead of double?

Use float (32-bit) when memory bandwidth, storage size, or SIMD throughput matters more than precision: GPU shader programs (where float is the native type), neural network weights and activations (where float precision exceeds model accuracy anyway), large arrays of sensor readings where ~7 significant digits is enough, and industrial protocol registers that physically transmit 32-bit IEEE 754 values (Modbus, CAN Open, PROFIBUS). Use double (64-bit) for scientific computing, financial calculations involving accumulated operations, physics simulations, astronomical coordinates, and any context where small rounding errors compound over many operations.

How do Octal and Hex relate to IEEE 754 float inspection?

Hexadecimal (base 16) maps 4 binary bits per digit, making it the most compact human-readable representation of a 32-bit float bit pattern — the 32-bit float 3.14 = 0x4048F5C3 (8 hex digits). Octal (base 8) maps 3 binary bits per digit — the same value is 0o10022172703 (11 octal digits). Some UNIX debuggers (od -f), legacy embedded tools, and assembly listings display memory in octal. This tool accepts both formats and converts between them automatically so you can work with whichever base your tool chain uses without manual conversion.

Related Tools

  • 3D Rotation Calculator - Free 3D rotation calculator online. Compose and chain multiple rotations — Euler angles, quaternions, axis-angle, and rotation matrices — and see the compound result in all four formats with live 3D visualization. Runs locally in your browser.
  • 3D Rotation Visualizer - Visualize 3D rotations using Quaternions, Euler Angles, and Rotation Matrices with interactive 3D visualization
  • 3D Rotation Converter - Convert between Quaternions, Euler Angles, and 3×3 Rotation Matrices bidirectionally with interactive 3D visualization
  • Number Base Converter - Convert numbers between binary, decimal, hexadecimal, and octal with precision
  • Endian Converter - Free online endian converter and byte swap calculator. Convert big endian to little endian with memory layout visualization, C bswap code generator, IEEE 754 float byte order, and htonl/ntohl reference for embedded and network developers

Bit Layout Visualization

Enter a value above to see the bit layout
IEEE 754 Converter & Field Breakdown
Valid: 0-9, ., e, +, - | Special: NaN, inf, -inf, -0 accepted
Valid: 0-9, A-F | Formats: 0x, x, \x, or plain (up to 8 digits)
Valid: 0-7 | Formats: 0o, o, \, 0-prefix, or plain (up to 11 digits)
Valid: 0-1 | Formats: 0b, b, or plain (exactly 32 bits)
Enter a value to see the decoded IEEE 754 fields
Need to swap the byte order of your float for a big-endian device? Use the Endian Converter to byte-swap the hex value, then paste it back here.