Floating Point to Binary Converter

Encodes a decimal number as IEEE 754 single-precision binary using the browser's native `DataView.setFloat32`, then displays the resulting 32 bits split into sign, exponent, and mantissa. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-27

Overview

Introduction

Floating-point numbers aren't stored as a simple binary version of their decimal digits — they follow a precise IEEE 754 layout of sign, exponent, and mantissa bits.

This tool shows exactly what that layout looks like for any decimal number, using the browser's own native float32 encoding rather than a hand-rolled approximation.

What Is Floating Point to Binary Converter?

A converter that encodes a decimal number as IEEE 754 single-precision (32-bit) binary and displays the full bit string plus its sign/exponent/mantissa breakdown.

It relies on the JavaScript engine's built-in `DataView.setFloat32`, so the result matches exactly what real single-precision hardware and software would produce.

How Floating Point to Binary Converter Works

The input is parsed as a number, written into a 4-byte `ArrayBuffer` with `DataView.prototype.setFloat32(0, value)` (using the platform's native IEEE 754 rounding), then read back byte-by-byte with `getUint8`.

Each of the 4 raw bytes is formatted as 8-bit binary and concatenated into a 32-character string, which is then split into its 1-bit sign, 8-bit exponent, and 23-bit mantissa sections for display.

When To Use Floating Point to Binary Converter

Use it when learning or teaching how floating-point numbers are actually stored in memory, bit by bit.

It's also useful for debugging low-level code, binary file formats, or network protocols that embed raw IEEE 754 float32 values.

Features

Advantages

  • Uses the browser's real IEEE 754 implementation, so results exactly match what any float32-compliant system would produce.
  • Breaks the 32 bits down into sign/exponent/mantissa for easier learning, not just a flat bit string.
  • Handles negative numbers, zero, and special values (Infinity, NaN) correctly.

Limitations

  • Only supports 32-bit single precision, not 64-bit double precision — the browser's native double-precision numbers are rounded to float32 before encoding.
  • Many decimal fractions (e.g. 0.1) cannot be represented exactly in binary floating point, so the encoded value may differ very slightly from the typed decimal.

Examples

A simple positive integer

Input

1

Output

00111111100000000000000000000000

1.0 encodes as sign 0, exponent 01111111 (127, the bias for exponent 0), and an all-zero mantissa (since 1.0 = 1.0 × 2^0).

A negative power of two

Input

-2

Output

11000000000000000000000000000000

-2.0 encodes as sign 1 (negative), exponent 10000000 (128, meaning an actual exponent of 1), and an all-zero mantissa (since 2.0 = 1.0 × 2^1).

Best Practices & Notes

Best Practices

  • Feed the result into the Binary to Floating Point Converter to confirm the round trip returns the original (or a very close) value.
  • Compare simple powers of two (1, 2, 4, 0.5) to build intuition for how the exponent field shifts predictably.

Developer Notes

Encoding is delegated entirely to the runtime's `DataView.setFloat32`/`getUint8` rather than a hand-written bit-manipulation algorithm, guaranteeing exact IEEE 754 rounding and special-value behavior without reimplementing the standard.

Floating Point to Binary Converter Use Cases

  • Learning or teaching the IEEE 754 single-precision bit layout
  • Debugging binary file formats or network protocols that embed float32 values
  • Verifying a hand-computed floating-point encoding exercise

Common Mistakes

  • Expecting an exact bit-for-bit match with a hand-computed encoding of a non-exactly-representable decimal like 0.1 — small rounding differences are normal, not a bug.
  • Confusing this with double-precision (64-bit) encoding, which uses a different bit layout (11 exponent bits, 52 mantissa bits).

Tips

  • Try 0 and -0 to see how IEEE 754 distinguishes positive and negative zero via the sign bit alone.
  • Try a very large number to see the exponent field grow while the mantissa still holds only the fractional precision.

References

Frequently Asked Questions