Floating Point Number to Hex Converter

Encodes a decimal floating-point number as the exact raw IEEE-754 bit pattern it occupies in memory, shown as hex, in either 32-bit single precision or 64-bit double precision, using DataView for an exact, standards-compliant encoding. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Every floating-point number is stored in memory as a precise sequence of bits, sign, exponent, and mantissa, packed according to the IEEE-754 standard.

This tool computes exactly those bits for any decimal value you enter and shows them as a hex string, in either 32-bit or 64-bit precision.

What Is Floating Point Number to Hex Converter?

An encoder that converts a decimal float into its raw IEEE-754 bit pattern, expressed as hex, at your choice of 32-bit (single) or 64-bit (double) precision.

This is not hexfloat (%a) notation, it's the literal bytes a float variable of that width would contain in memory, with no dot or exponent marker in the output at all.

How Floating Point Number to Hex Converter Works

The input value is written into an ArrayBuffer using a DataView's `setFloat32` or `setFloat64` method, which performs the exact IEEE-754 encoding specified by the JavaScript language standard.

The buffer's raw bytes are then read back out as an unsigned 32-bit integer (or two, for 64-bit) via `getUint32`, and formatted as an uppercase, zero-padded hex string of the appropriate length (8 digits for 32-bit, 16 for 64-bit).

When To Use Floating Point Number to Hex Converter

Use it when you need the literal bytes a float occupies in memory, for binary file formats, network protocols, low-level debugging, or writing test vectors that check bit-exact IEEE-754 encoding.

If you instead want a human-readable notation for the value (useful in C99 source code or when comparing to printf's %a output), use Float to Hexfloat Converter instead.

Features

Advantages

  • Exact, standards-compliant IEEE-754 encoding via the browser's native DataView implementation, not a hand-rolled bit-manipulation approximation.
  • Supports both single (32-bit) and double (64-bit) precision.
  • Correctly handles zero, negative zero, Infinity, and NaN.

Limitations

  • Only supports the two standard IEEE-754 binary widths (32-bit and 64-bit); extended or half (16-bit) precision aren't offered.
  • Converting a value to 32-bit precision may round it, since single precision has less mantissa precision than a typical decimal input or double-precision source value.

Examples

Encoding 1.0 as a 32-bit float

Input

1.0 (32-bit)

Output

3F800000

1.0's IEEE-754 single-precision bit pattern is the well-known constant 0x3F800000.

Encoding 1.0 as a 64-bit float

Input

1.0 (64-bit)

Output

3FF0000000000000

1.0's IEEE-754 double-precision bit pattern is 0x3FF0000000000000, using the wider 11-bit exponent and 52-bit mantissa.

Best Practices & Notes

Best Practices

  • Use 64-bit precision unless you specifically need to match a 32-bit float field or variable; it preserves far more of a decimal value's original precision.
  • If a 32-bit encoding looks surprising, remember it only has 23 mantissa bits, some decimal values that look exact will be rounded.

Developer Notes

Implemented with `DataView.prototype.setFloat32`/`setFloat64` followed by `getUint32` reads (big-endian, matching how IEEE-754 bit layouts are conventionally described high-bit-first), then `.toString(16).toUpperCase().padStart(...)`; verified against the well-known constants 0x3F800000 (1.0f), 0xC0000000 (-2.0f), 0x3F000000 (0.5f), and 0x3FF0000000000000 (1.0 double).

Floating Point Number to Hex Converter Use Cases

  • Producing exact IEEE-754 test vectors for a binary file format or protocol
  • Debugging why two floats that look equal in decimal differ slightly in memory
  • Learning how IEEE-754's sign/exponent/mantissa layout actually works for a real value

Common Mistakes

  • Confusing this raw bit-pattern output with hexfloat (%a) notation, they represent the same value but in entirely different textual formats.
  • Expecting a 32-bit and 64-bit encoding of the same value to share a simple prefix/suffix relationship; they don't, since the two formats use different bit widths throughout.

Tips

  • Use Hex to Floating Point Number Converter to decode this tool's output back into a decimal value and confirm a round trip.
  • If you need the human-readable %a form instead of raw bits, use Float to Hexfloat Converter.

References

Frequently Asked Questions