IEEE 754 Converter: Convert Decimal and Bits

Round a decimal or hex float to IEEE 754 binary16, binary32, or binary64, or decode a raw bit pattern. Each result shows the sign, biased exponent, stored exponent, fraction bits, and exact mathematical value.

Decimal (0.1, -0, 1.25e-3), C hex float (0x1.8p-1), or raw bits (0x3f800000, or 16, 32, or 64 binary digits). Also Infinity, nan(0x123), and snan(1). Underscores may separate digits.

Format
Input kind

Result

How it works

A finite binary floating-point number is a sign, a biased exponent field, and fraction bits. For a normal number the stored exponent is that field minus the bias, and the value is (+ or -) 1.fraction times 2 to that power. The leading 1 is stored implicitly. Subnormals store an all-zero exponent field and use 2 to the power of 1 minus the bias, with a leading 0. The value formula on each result is the integer significand times a power of two, which is the same real number.

  • binary16 is 1 + 5 + 10 bits, bias 15, range up to 65504, smallest subnormal 2^-24.
  • binary32 is 1 + 8 + 23 bits, bias 127, smallest subnormal 2^-149.
  • binary64 is 1 + 11 + 52 bits, bias 1023, smallest subnormal 2^-1074.
  • Rounding is ties-to-even, straight into the format you asked for. A decimal or hex float that is not representable is marked inexact, with the direction and the exact absolute error. Halfway cases use the neighbor whose significand integer is even. A tie past the largest finite value becomes infinity. A tie between zero and the smallest subnormal becomes zero.
  • binary16, binary32, and binary64 are rounded with integer arithmetic. binary16 is not rounded through a wider host floating-point type, so some decimals differ from a convert-to-binary64-then-narrow path.
  • +0 and -0 are both real zero and keep different sign bits. Infinities use an all-ones exponent and a zero fraction. NaN uses an all-ones exponent and a nonzero fraction. The top fraction bit is the quiet bit under IEEE 754-2019: 1 means quiet, 0 means signaling. nan is the canonical quiet NaN, nan(payload) sets the low payload bits, and snan(1) is the smallest signaling NaN. Payloads are shown, not given extra meaning, and signaling NaNs are not trapped.
  • Auto mode reads Infinity, nan, and snan as specials; 0x1.8p-1 as a C hex float (binary exponent); 0x3f800000 or 0b plus a full word as raw bits; and a spaced 16, 32, or 64-bit pattern of 0 and 1 as raw binary. A bare string of 0 and 1 with no spaces is a decimal, and so is an exponent such as 1e-4. Prefix a hex word with 0x when its only letter is e, as in 0x3e80. Sixteen bare 0 and 1 digits in raw mode need a 0b or 0x prefix unless a single format removes the ambiguity.
  • Hex words are the IEEE field order, sign first. Little-endian bytes are those same bits reversed by byte, which is the usual memory order on little-endian machines.
  • Limits: 12000 characters, 2000 significant decimal digits, decimal exponents from -10000 to 10000, and hex-float binary exponents from -1000000 to 1000000. Only binary16, binary32, and binary64, and only ties-to-even. This page does not convert bfloat16, binary128, decimal floating point, or 80-bit extended values, and it does not add or multiply.
  • Conversion stays in this page. Values are not saved or uploaded.