Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
IBM hexadecimal floating-point
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Single-precision 32-bit == A [[single-precision floating-point format|single-precision]] HFP number (called "short" by IBM) is stored in a 32-bit word: :{| |- style="text-align:center" |style="width:20px"|1 |style="width:20px"| |style="width:50px"|7 |style="width:20px"| |style="width:20px"| |style="width:210px"|24 |style="width:20px"| |style="text-align:left"|''(width in bits)'' |- style="text-align:center" |colspan="1" style="text-align:center;background-color:#FC9"|S |colspan="3" style="text-align:center;background-color:#99F"|Exp |colspan="3" style="text-align:center;background-color:#9F9"|Fraction |colspan="1" style="text-align:center;background-color:#FFF"| |- style="text-align:center" |31 |30 |... |24 |23 |... |0 |align="left"|''(bit index)''* |- |colspan="8"| ''* IBM documentation numbers the bits from left to right, so that the most significant bit is designated as bit number 0.'' |} In this format the initial bit is not suppressed, and the radix (hexadecimal) point is set to the left of the significand (fraction in IBM documentation and the figures). Since the base is 16, the exponent in this form is about twice as large as the equivalent in IEEE 754, in order to have similar exponent range in binary, 9 exponent bits would be required. === Example === Consider encoding the value β118.625 as an HFP single-precision floating-point value. The value is negative, so the sign bit is 1. The value 118.625<sub>10</sub> in binary is 1110110.101<sub>2</sub>. This value is normalized by moving the radix point left four bits (one hexadecimal digit) at a time until the leftmost digit is zero, yielding 0.01110110101<sub>2</sub>. The remaining rightmost digits are padded with zeros, yielding a 24-bit fraction of .0111 0110 1010 0000 0000 0000<sub>2</sub>. The normalized value moved the radix point two hexadecimal digits to the left, yielding a multiplier and exponent of 16<sup>+2</sup>. A bias of +64 is added to the exponent (+2), yielding +66, which is 100 0010<sub>2</sub>. Combining the sign, exponent plus bias, and normalized fraction produces this encoding: :{| |- style="text-align:center" |style="width:20px;text-align:center;background-color:#FC9"|S |style="width:90px;text-align:center;background-color:#99F"|Exp |style="width:250px;text-align:center;background-color:#9F9"|Fraction |style="text-align:center;background-color:#FFF"| |- style="text-align:center" |style="text-align:center;background-color:#FEC"|{{mono|1}} |style="text-align:center;background-color:#CCF"|{{mono|100 0010}} |style="text-align:center;background-color:#CFC"|{{mono|0111 0110 1010 0000 0000 0000}} |style="text-align:center;background-color:#FFF"| |} In other words, the number represented is β0.76A000<sub>16</sub> Γ 16<sup>66 β 64</sup> = β0.4633789β¦ Γ 16<sup>+2</sup> = β118.625 === Largest representable number === :{| |- style="text-align:center" |style="width:20px;text-align:center;background-color:#FC9"|S |style="width:90px;text-align:center;background-color:#99F"|Exp |style="width:250px;text-align:center;background-color:#9F9"|Fraction |style="text-align:center;background-color:#FFF"| |- style="text-align:center" |style="text-align:center;background-color:#FEC"|{{mono|0}} |style="text-align:center;background-color:#CCF"|{{mono|111 1111}} |style="text-align:center;background-color:#CFC"|{{mono|1111 1111 1111 1111 1111 1111}} |style="text-align:center;background-color:#FFF"| |} The number represented is +0.FFFFFF<sub>16</sub> Γ 16<sup>127 β 64</sup> = (1 β 16<sup>β6</sup>) Γ 16<sup>63</sup> β +7.2370051 Γ 10<sup>75</sup> === Smallest positive normalized number === :{| |- style="text-align:center" |style="width:20px;text-align:center;background-color:#FC9"|S |style="width:90px;text-align:center;background-color:#99F"|Exp |style="width:250px;text-align:center;background-color:#9F9"|Fraction |style="text-align:center;background-color:#FFF"| |- style="text-align:center" |style="text-align:center;background-color:#FEC"|{{mono|0}} |style="text-align:center;background-color:#CCF"|{{mono|000 0000}} |style="text-align:center;background-color:#CFC"|{{mono|0001 0000 0000 0000 0000 0000}} |style="text-align:center;background-color:#FFF"| |} The number represented is +0.1<sub>16</sub> Γ 16<sup>0 β 64</sup> = 16<sup>β1</sup> Γ 16<sup>β64</sup> β +5.397605 Γ 10<sup>β79</sup>. === Zero === :{| |- style="text-align:center" |style="width:20px;text-align:center;background-color:#FC9"|S |style="width:90px;text-align:center;background-color:#99F"|Exp |style="width:250px;text-align:center;background-color:#9F9"|Fraction |style="text-align:center;background-color:#FFF"| |- style="text-align:center" |style="text-align:center;background-color:#FEC"|{{mono|0}} |style="text-align:center;background-color:#CCF"|{{mono|000 0000}} |style="text-align:center;background-color:#CFC"|{{mono|0000 0000 0000 0000 0000 0000}} |style="text-align:center;background-color:#FFF"| |} Zero (0.0) is represented in normalized form as all zero bits, which is arithmetically the value +0.0<sub>16</sub> Γ 16<sup>0 β 64</sup> = +0 Γ 16<sup>β64</sup> β +0.000000 Γ 10<sup>β79</sup> = 0. Given a fraction of all-bits zero, any combination of positive or negative sign bit and a non-zero biased exponent will yield a value arithmetically equal to zero. However, the normalized form generated for zero by CPU hardware is all-bits zero. This is true for all three floating-point precision formats. Addition or subtraction with other exponent values can lose precision in the result.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)