corrected description of bit patterns for NaN and Inf

This commit is contained in:
Perry Kivolowitz 2022-06-20 10:37:15 -05:00
parent 412e814d1d
commit 607eda78bd

View file

@ -213,9 +213,10 @@ NaN: 1
Inf: 0 Inf: 0
``` ```
`Nan` is true (for `float`) when its exponent is 0xFF and the sign `Nan` is true (for `float`) when its exponent is 0xFF and fraction
is 0. So, you'll is not zero.
never get a `float` that is 2 raised to the power of 128 because
You'll never get a `float` that is 2 raised to the power of 128 because
that value is reserved for `NaN` and `Inf`. that value is reserved for `NaN` and `Inf`.
How about `Inf`? How about `Inf`?
@ -231,8 +232,8 @@ Inf: 1
``` ```
Once again, notice the out-of-bounds value for the exponent: 0xFF. Once again, notice the out-of-bounds value for the exponent: 0xFF.
Second notice that the sign bit is 1. This stands for `Inf` or Secondly, the fraction is fully zero. The sign bit specifies negative
an infinite result. or positive infinity.
## Testing for Naughty Values ## Testing for Naughty Values
@ -247,4 +248,4 @@ Both of these functions work with `double` and `float`.
Once a variable goes `NaN` or `Inf`, all subsequent operations Once a variable goes `NaN` or `Inf`, all subsequent operations
will remain `NaN` or `Inf` until the variable is reset to a will remain `NaN` or `Inf` until the variable is reset to a
valid number. valid number. That is, 1 + `Inf` is `Inf`, for example.