
60 GPGPU Programming for Games and Science
if (exponent < binaryN : : NUM TRAIL ING BITS )
{
// Process the biased exponent and t r ai l in g simultaneously .
UInteger nonnegative = abs(x ); // a bs ( x) se ts s ign b it t o z e r o .
// E x t rac t d .
Integer d shi ft = binaryN : : NUM
TRAILING BITS − exponent ;
UInteger d = (nonnegative >> dshift );
// E x t rac t r .
Integer r sh if t = binaryN : : NUM
ENCODING BITS − dshift ;
UInteger r = (nonnegative << rshift );
// Enable for RoundToIntegralExact:
// i f ( r > 0) { Raise F l a gs ( SIGNAL
INEXACT ) ; }
// Round toward ne ga ti ve . I f the ” e l s e ” c la u se were present ,
// it would simply truncate ...