point at extreme right of mantissa. if (*ibeta == 2 && !i) --(*maxexp); if (i 20) --(*maxexp); if (a != y) *maxexp -= 2; *xmax=one-(*epsneg); if ((*xmax)*one != *xmax) *xmax=one-beta*(*epsneg); *xmax /= (*xmin*beta*beta*beta); i=(*maxexp)+(*minexp)+3; for (j=1;j | 894 Chapter 20. Less-Numerical Algorithms point at extreme right of mantissa. if ibeta 2 i maxexp if i 20 maxexp if a y maxexp - 2 xmax one- epsneg if xmax one xmax xmax one-beta epsneg xmax xmin beta beta beta i maxexp minexp 3 for j 1 j i j if ibeta 2 xmax xmax else xmax beta Some typical values returned by machar are given in the table above. IEEE-compliant machines referred to in the table include most UNIX workstations SUN DEC MIPS and Apple Macintosh Ils. IBM PCs with floating co-processors are generally IEEE-compliant except that some compilers underflow intermediate results ungracefully yielding irnd 2 rather than 5. Notice as in the case of a VAX fourth column that representations with a phantom leading 1 bit in the mantissa achieve a smaller eps for the same wordlength but cannot underflow gracefully. CITED REFERENCES AND FURTHER READING Goldberg D. 1991 ACM Computing Surveys vol. 23 pp. 5-48. Cody . 1988 ACM Transactions on Mathematical Software vol. 14 pp. 303-311. 1 Malcolm . 1972 Communications of the ACM vol. 15 pp. 949-951. 2 IEEE Standard for Binary Floating-Point Numbers ANSI IEEE Std 754-1985 New York IEEE 1985 . 3 Gray Codes A Gray code is a function G i of the integers i that for each integer N 0 is one-to-one for 0 i 2N - 1 and that has the following remarkable property The binary representation of G i and G i 1 differ in exactly one bit. An example of a Gray code in fact the most commonly used one is the sequence 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 and 1000 for i 0 . 15. The algorithm for generating this code is simply to form the bitwise exclusive-or XOR of i with i 2 integer part . Think about how the carries work when you add one to a number in binary and you will be able to see why this works. You will also see that G i and G i 1 differ in the bit position of the rightmost zero bit of i prefixing a leading zero if necessary . The spelling is Gray not gray The codes are named after one .