
IEEE 754 converter
Inspect a floating-point number’s IEEE 754 binary and hexadecimal representation in 32 or 64 bits.
The hexadecimal representation uses big-endian byte order. Subnormal numbers and signed zero are preserved.
Method and assumptions
Method version 1.0.0 · Updated
Encode a floating-point number
Formula: Encodes real numbers as a sign, biased exponent and fraction using IEEE 754 formats.
Shows the bits and hexadecimal bytes in network (big-endian) order. Single precision rounds to the nearest 32-bit float; values that overflow the format are rejected. The decoded value is the value actually represented.
- value
- Decimal number
- precision
- IEEE 754 format
Accepts finite decimal numbers and scientific notation. Non-finite values and single-precision overflow are rejected.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
const buffer = new ArrayBuffer(4);
new DataView(buffer).setFloat32(0, 1.5, false);
console.log(new DataView(buffer).getUint32(0, false).toString(16).toUpperCase()); // 3FC00000TypeScript
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer); view.setFloat32(0, 1.5, false);
console.log(view.getUint32(0, false).toString(16).toUpperCase()); // 3FC00000Python
import struct
print(struct.pack('>f', 1.5).hex().upper()) # 3FC00000Java
int bits = Float.floatToIntBits(1.5f);
System.out.printf("%08X%n", bits); // 3FC00000C#
int bits = BitConverter.SingleToInt32Bits(1.5f);
Console.WriteLine($"{bits:X8}"); // 3FC00000More languages
C
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int main(void) { float f = 1.5f; uint32_t bits; memcpy(&bits, &f, 4); printf("%08X\n", bits); } // 3FC00000 on IEEE-754 hostsC++
#include <bit>
#include <cstdint>
#include <cstdio>
int main() { auto bits = std::bit_cast<std::uint32_t>(1.5f); std::printf("%08X\n", bits); } // 3FC00000, C++20PHP
echo strtoupper(bin2hex(pack('G', 1.5))); // 3FC00000 (big-endian float32)PowerShell
$bits = [BitConverter]::SingleToInt32Bits([single]1.5)
'{0:X8}' -f $bits # 3FC00000