Professional Documents
Culture Documents
Converting floating-point numbers from the hexadecimal into the decimal format
The following diagram shows the arrangement of bits of IEEE floating-point numbers. Bit 31 =
sign, bits 23 to 30 = exponent and bits from 0 to 22 = mantisse.
Bit
31 24 23 16 15 8 7 0
V E E E E E E E E M M M M M M M M M M M M M M M M M M M M M M M
Exponent Mantisse
Sign
The sign, exponent (exp) and the decimal point (M) of the number are saved in a floating-point
number. They still have to be determined.
The following schematic shows how all of the three components are selected. In this case the
maximum frequency is considered (50.0Hz float: 4248 0000 hex ⇒ 50.0 dec)
4 2 4 8 0 0 0 0
Bit
31 24 23 16 15 8 7 0
0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
… … … …
8 4 9 0
Sign (VZ)
The decimal number must be represented in the form (-1)VZ · 1.M · 2Exp - 127.
Let's consider this conversion using an example.
The maximum frequency (P1082) should, e.g. be set to 87.0Hz; to do this the following
conversion is required:
• Which power of 2 fits in the number so that the rest results in a "one (decimal) point
something"?
26 = 64 ⇒
87 = 64 · (87/64) =
= 26 · (1 + 87/64 – 1) =
= 26 · (1 + (87/64 – 64/64)) =
= 2133-127 · (1 + 23/64) =
= 2133-127 · (1 + 92/256) =
= 2133-127 · (1 + (80+12)/256) =
⇒ VZ = 0,
Exp = 133dec = 85hex,
Mantisse = 5.12dec
0 8 5 5 12
0 1 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 …
4 2 A E 0 0 0 0
Send via Profibus: 42AE 0000.