IEEE 754 Converter
Convert decimal numbers to IEEE 754 floating point representation.
How the IEEE 754 Converter works
The IEEE 754 converter translates decimal numbers to 32-bit single-precision and 64-bit double-precision floating-point binary representations and back. It shows the sign bit, biased exponent, and mantissa fields separately with colour-coding, making it an invaluable teaching tool for computer science students, embedded developers debugging register values, and anyone who needs to understand why 0.1 + 0.2 ≠ 0.3 in floating-point arithmetic.
Single-precision (32-bit) structure
IEEE 754 single precision uses 1 sign bit, 8 exponent bits (bias 127), and 23 mantissa (significand) bits. The value is computed as: (−1)^sign × 2^(exponent−127) × 1.mantissa. For example, the decimal 5.75 becomes sign=0, exponent=10000001 (129, biased from 2), mantissa=01110000000000000000000 — giving the 32-bit hex representation 0x40B80000.
Special values: NaN, Infinity, and zero
IEEE 754 reserves special bit patterns for exceptional values. An exponent of all-zeros with a zero mantissa represents positive or negative zero (two representations of zero!). An exponent of all-ones (255) with a zero mantissa represents ±Infinity. An exponent of all-ones with any non-zero mantissa is NaN (Not a Number). Subnormal numbers use an exponent of zero with non-zero mantissa to represent values smaller than the smallest normal float.
Double precision and precision limits
Double precision (64-bit) uses 1 sign bit, 11 exponent bits (bias 1023), and 52 mantissa bits, providing roughly 15–17 significant decimal digits. Single precision provides only 6–9 digits. Many financial and scientific applications require doubles; embedded systems often use singles to save memory and improve speed on hardware without FPU double support. The converter handles both formats to help diagnose precision-related bugs.
Python and C usage
In Python, struct.pack('!f', 5.75) encodes a float to its 4-byte IEEE 754 big-endian representation. struct.unpack('!f', b'\x40\xb8\x00\x00') decodes it back. In C, a union between float and uint32_t provides bit-level access to the floating-point representation for inspection or manipulation. The converter's hex output is directly usable in both contexts for verifying serialisation and register values.
Frequently asked questions
- What is IEEE 754?
- IEEE 754 is the international standard for floating-point arithmetic, adopted by virtually all modern processors and programming languages. It defines how decimal numbers are stored in binary using three fields: a sign bit (0 for positive, 1 for negative), an exponent field (biased encoding of the power of 2), and a mantissa (fraction) field that stores the significant digits.
- Why do floating point numbers have rounding errors?
- Most decimal fractions cannot be represented exactly in base-2 (binary). For example, the decimal value 0.1 in binary is the repeating fraction 0.000110011001100…, which gets truncated at the length of the mantissa field. This truncation introduces a small rounding error. Summing many such numbers accumulates these errors, which is why financial calculations should use integer arithmetic or decimal libraries rather than floating-point types.
- What is the difference between float and double?
- A 32-bit single-precision float has 1 sign bit, 8 exponent bits, and 23 mantissa bits, giving approximately 7 significant decimal digits of precision. A 64-bit double-precision double has 1 sign bit, 11 exponent bits, and 52 mantissa bits, giving approximately 15 significant decimal digits. Use double when precision matters; use float when memory bandwidth is critical, such as in graphics shaders or large numerical arrays.
Related tools
- Resistor Color Code Calculator
Decode resistor color bands. Supports 4-band and 5-band.
- Ohm's Law Calculator
Calculate voltage, current, resistance, or power using Ohm's Law.
- Voltage Divider Calculator
Calculate output voltage for a resistor voltage divider.
- 555 Timer Calculator
Calculate frequency, duty cycle, and timing for 555 timer circuits.
- CRC Calculator Online — CRC-8, CRC-16, CRC-32 & Modbus
Calculate CRC checksums online — CRC-8, CRC-16/MODBUS, CRC-16/CCITT, CRC-32, CRC-32C and more. Shows HEX, DEC and BIN. Supports text and hex input. Browser-only, no upload.