Hongmu Notes

Restore floating point number from hexadecimal

Restore floating point numbers from hexadecimal for interpreting protocols and dumping data: paste the 0x bit string or binary bit string into the input box to get the corresponding value.
100% Browser local processing 0 Data upload

🔬 IEEE 754 bit pattern parsing

💡 Instructions for use

  • Three inputs are supported: decimal number (0.1), hexadecimal (0x3FB999999999999A) and binary bit string of corresponding length.
  • Single precision and double precision check length respectively: single precision hexadecimal 8 bits, binary 32 bits; double precision hexadecimal 16 bits, binary 64 bits.
  • There is a special case when the exponent bits are all 0s or all 1s: zero or a denormalized number, infinity or a non-numeric NaN, respectively, and are clearly marked in the result area.
  • The standardized form is given in one line as "sign × mantissa × 2 raised to the power of the exponent" to facilitate comparison with the notation in the textbook.

Restore floating point numbers from hexadecimal for interpreting protocols and dumping data: paste the 0x bit string or binary bit string into the input box to get the corresponding value.

Input format requirements

AccuracyHexadecimal lengthBinary length
single precision832
double precision1664

What should we pay attention to in byte order?

Tools are parsed bitwise from high bit to low bit. If the original data is a memory dump or network byte stream, it is usually stored in bytes. When encountering little-endian arrangement, you need to reverse the byte order before inputting it, otherwise you will get completely different values. The judgment method is simple: if the restoration result is a very small denormalized number or a very large number, it is likely that the byte order is reversed.

The result area also provides bit pattern and segmentation information, which can be used to confirm whether the parsing direction is correct. If the restored value is consistent with the protocol document, it means that the endianness is correct.

Reverse conversion is used to restore the original bytes read in the packet capture or file into readable values. During operation, first confirm whether the length is four bytes or eight bytes, and then confirm the byte order. Wrong selection of the two parameters will result in seemingly reasonable incorrect results.

If the restored value obviously exceeds the business scope, for example, if the temperature appears to be tens of thousands of degrees, it usually means that the parameter selection is wrong. At this time, change the byte order or the precision and try again. In most cases, it will return to normal immediately.

If the restoration result is obviously unreasonable, try reversing the byte order and re-entering.

📖 Glossary

IEEE 754
An international standard that defines how floating-point numbers are stored and operated on in computers using binary systems. It specifies the bit layout for single-precision and double-precision.
sign bit
The highest bit, 0 for positive numbers and 1 for negative numbers; it determines the sign rather than the size.
Exponent bit
A section immediately following the sign bit, 8 bits in single precision and 11 bits in double precision, used to represent powers of 2.
offset
A fixed value added when the exponent is stored, 127 for single precision and 1023 for double precision, used to represent negative exponents.
mantissa digits
The binary significant digits after the decimal point, 23 bits for single precision and 52 bits for double precision, determine the precision of the value.
Normalized number
The normal case where the exponent bits are neither all 0s nor all 1s, in which case the integer bit 1 is implied and is written in the form of 1.mantissa .
denormalized number
When the exponent bits are all 0 and the mantissa is not 0, it is used to represent a number smaller than the minimum normalized number, and the accuracy will be reduced.
NaN
Non-numeric, the exponent bits are all 1 and the mantissa is not 0. Any comparison with NaN returns false, and special methods are required for judgment.
infinity
The exponent bits are all 1 and the mantissa is 0, indicating an overflow result, which can be divided into positive and negative.
rounding error
The deviation caused by truncation or rounding when converting decimal fractions into binary may affect the comparison results after accumulation.

🔗 All keywords and tutorials

Keywords page of the tool12a

Return to tool home page

❓ FAQ

What happens if I enter 16 digits of hexadecimal but select single precision??
It will prompt that the length does not match. Single precision corresponds to 8-digit hexadecimal, and you need to switch to double precision in the precision drop-down box first.
Can a binary bit string contain spaces??
Yes, the tool will automatically remove spaces and then verify the length.