This calculator converts a decimal number into its IEEE 754 half-precision (binary16) binary representation, showing the sign, exponent, and mantissa bits, and also converts a hex or binary half-precision value back into decimal. You enter a decimal number, or a 16-bit hex/binary string, and get the corresponding IEEE half-precision bit pattern and the decimal value it represents. The tool uses the standard IEEE 754-2008 binary16 format: 1 sign bit, 5 exponent bits, and 10 fraction bits.
Formula
The IEEE 754 half-precision format (binary16) stores a number in 16 bits using three fields:
- Sign (1 bit): 0 for positive, 1 for negative.
- Exponent (5 bits): biased by 15. The stored exponent is the actual exponent plus 15.
- Fraction (10 bits): the fractional part of the significand (mantissa). The leading 1 is implicit for normal numbers.
The value of a normal half-precision number is:
(-1)^sign × 1.fraction × 2^(exponent - 15)
where exponent is the 5-bit stored exponent (0 to 31). Special cases:
- Exponent = 0, fraction = 0: zero (±0).
- Exponent = 0, fraction ≠ 0: subnormal numbers, value = (-1)^sign × 0.fraction × 2^(-14).
- Exponent = 31, fraction = 0: infinity (±∞).
- Exponent = 31, fraction ≠ 0: NaN (Not a Number).
The calculator converts a decimal input to its nearest half-precision representation, rounding to the nearest even on ties. It also converts a hex input (like 0x3E00) back to decimal.
Worked Example
Using the default decimal value of 1.5:
- Sign: positive → sign bit = 0.
- Normalize 1.5 in binary: 1.1₂ (since 1.5 = 1 + 0.5). The exponent is 0.
- Biased exponent = 0 + 15 = 15 → binary 01111.
- Fraction (after the leading 1) = 0.1₂ → 10 bits: 1000000000.
- Combine: sign 0, exponent 01111, fraction 1000000000 → bits = 0 01111 1000000000 = 0x3E00.
The calculator outputs bits = 0 01111 1000000000 and hex = 0x3E00. The hex input 0x3E00 converts back to decimal 1.5, as shown by the dec output.
Range and Precision Limits
Half precision is a compact format with significant trade-offs:
- Maximum finite value: 65504 (when exponent = 30, fraction = 1023).
- Minimum positive normal: 2^(-14) ≈ 0.000061035.
- Minimum positive subnormal: 2^(-24) ≈ 0.0000000596.
- Precision: about 3 decimal digits (since 10 fraction bits give ~3.3 decimal digits).
Any decimal with more than ~3 significant digits will be rounded when converted to half precision. For example, 0.1 becomes 0.0999755859375 in half precision. This is normal and expected.
When to Use Half Precision
Half precision is used where memory and bandwidth matter more than precision, and values stay within ±65504. Common applications include:
- Machine learning inference and training (many models tolerate reduced precision).
- Graphics shaders and texture formats (e.g., RGBA16F).
- Embedded systems with limited storage.
- Scientific simulations where dynamic range is small.
If your values exceed 65504 or you need more than 3 significant digits, use single (32-bit) or double (64-bit) precision instead.
Common Mistakes and Misconceptions
People often confuse the number of exponent bits with precision. The 5-bit exponent gives a wide range, but the 10-bit fraction limits precision. Another mistake is forgetting that the exponent is biased by 15, not 16 or 127 (the single-precision bias). Also, subnormal numbers fill the gap between zero and the smallest normal number, but they have reduced precision because the leading 1 is not stored.
When converting decimal to half precision, the result is the nearest representable value, not the exact decimal. For instance, 0.1 is not stored exactly; it becomes 0.0999755859375. This is not a bug—it’s the inherent limitation of binary floating-point.
How to Read the Bit Pattern
The output shows the 16 bits grouped as sign, exponent, fraction. For example, 0 01111 1000000000:
- Sign bit: 0 → positive.
- Exponent bits: 01111 = 15 → actual exponent = 15 – 15 = 0.
- Fraction bits: 1000000000 → fraction = 0.5 (binary 0.1).
- Value = 1.5 × 2^0 = 1.5.
For subnormals (exponent = 0), the value is 0.fraction × 2^(-14). For infinity, the fraction is zero; for NaN, the fraction is non-zero.
Comparing with Single and Double Precision
Here’s a quick comparison of IEEE 754 formats:
- Half (binary16): 16 bits, exponent bias 15, ~3 decimal digits precision, max 65504.
- Single (binary32): 32 bits, exponent bias 127, ~7 decimal digits precision, max ~3.4×10^38.
- Double (binary64): 64 bits, exponent bias 1023, ~15 decimal digits precision, max ~1.8×10^308.
If you need to store many values and memory is tight, half precision can be a good trade-off. But always test whether the reduced precision affects your results.
Frequently Asked Questions
What is the range of half precision? The largest finite number is 65504, and the smallest positive subnormal is about 5.96×10^(-8). Values outside this range overflow to infinity or underflow to zero.
Why is 0.1 not stored exactly? Because 0.1 in binary is a repeating fraction (0.0001100110011…), and half precision has only 10 fraction bits. It is rounded to the nearest representable value, which is 0.0999755859375.
What is the difference between normal and subnormal numbers? Normal numbers have an implicit leading 1 and exponent between 1 and 30. Subnormals (exponent = 0) have an implicit leading 0 and allow values closer to zero, but with fewer bits of precision.
How do I convert a hex value like 0x3E00 to decimal? Split into bits: sign=0, exponent=01111 (15), fraction=1000000000 (0.5). Value = 1.5 × 2^(15-15) = 1.5. The calculator does this automatically.
Can I use half precision for financial calculations? No. Financial calculations require exact decimal arithmetic, not binary floating-point. Half precision’s ~3-digit precision is far too low, and even single/double precision can introduce rounding errors.
What happens if I enter a number larger than 65504? The calculator limits input to ±65504. In real hardware, values above the maximum become infinity. Values below the smallest subnormal become zero.
Related
Formula used
in x | Decimal value | - | 1.5 | -65504 | 65504 in h | Hex (e.g. 0x3E00) | - | 0x3E00 | 0x0000 | 0xFFFF out bits | Binary16 bits (sign exp mantissa) | - | bin16(x) | 0 out hex | Hex representation | - | hex16(x) | 0 out dec | Decimal from hex | - | dec16(h) | 6
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Measuring Light Speed & Wavelength: How It Works
- Draco Race Blox Fruits: How to Get It
- ES File Explorer Tips & Tricks That Actually Work
- Remove Google FRP Lock on Oppo: Step-by-Step
- Forza Horizon 6: Unlock Legend Island & Earn Horizon Legend
- Clean Hair Dryer Filter: Improve Airflow