
CPU Computing 45
// x = quiet NaN
}
else
{
// x = signaling NaN
}
// p a y l o a d = t & NAN
PAYLOAD MASK
}
}
LISTING 2.11: The general decoding of floating-point numbers.
The pseudocode that extracts the sign, biased exponent, and trailing sig-
nificand may be encapsulated, as shown in Listing 2.12. The combination of
parts into a number may also be encapsulated. There is no reason to shift the
sign bit into the lowest-order bit.
void GetEncoding ( binaryN x , UInteger& sign , UInteger& biased ,
UInteger& tr ai lin g )
{
sign = (x . encoding & SIGN
MASK ) ;
b i a s e d = ( x . e n c o d i n g & BIASED
EXPONE NT MASK) >> NUM TRAILING BITS ;
t r a i l i n g = ( x .