3DSoftware.com > Programming > Floating Point > Page 5
Floating Point Numbers  Page 5
 
Wide Floating Point
 
Digit Ordering
 
In a WideFloat number, each digit is 30 bits, stored in a 32-bit digit packet. This is like WideInteger numbers, but with significance of the digits in the reverse direction.
 
Assume the digit packets of a wide number are declared as follows in C/C++:
 
unsigned int d[6];
 
For a WideInteger, d[0] would be the least significant digit, and d[5] the most significant digit.
For a WideFloat, d[0] would be the most significant digit, and d[5] the least significant digit.
 
For WideInteger these digits are to the left of the radix point in reverse order:   d5…d1d0.
 
For WideFloat the first digit is to the left of the radix point, with the remaining digits following in sequence after the radix point:   d0.d1d2…
 
In the following examples on this page, all digit packets that are not specified are assumed to be zero.
 

 
The number 0x200000030000004 is stored in a WideInteger as:
 
d[0]=4;
d[1]=3;
d[2]=2;
 
That same number is stored in a WideFloat as:
 
d[0]=2;
d[1]=3;
d[2]=4;
 
The WideFloat exponent will be 2, indicating that the radix point is two digit positions to the right compared to a standard normalized significand of d0.d1d2…
 

 
To store the number 1.0 in a WideFloat:
 
d[0]=1;
 
The exponent will be 0.  The significand is already in normal form in which the radix point is assumed to be between d[0] and d[1].
 

 
Next we will store the number 1.5.  That is 1½, which is (1 + 1/2):
 
d[0]=1;
d[1]=0x20000000;
 
The exponent will be 0.  The significand is already in normal form.
To understand why d[1] is 0x20000000, consider the polynomial with t = 230:
 
 d0.d1d2d3...    =   ( d0 )t0 + ( d1 )t–1 + ( d2 )t–2 + ( d3 )t–3 + ...
 
=   d0 + d1 / t1 + d2 / t2 + d3 / t3 + ...
 
=   d0 + d1 / 230 + d2 / 256 + d3 / 284 + ...
 
 1.5    =   d0 + d1 / 230
 
 1.5    =   1 + d1 / 230
 
 ½    =   d1 / 230
 
d1 / 230    =   ½ 
 
 d1    =   ( ½ )230
 
=   230 / 2
 
=   229
 
=   0x20000000 
 
 

 
Now we will store the number 0.5, which is (0 + 1/2):
 
d[0]=0x20000000;
 
The exponent will be –1, indicating that the radix point must move one digit position to the left compared to the standard normalized significand of d0.d1d2… (i.e., multiplied by t–1).
 
 
—  Page 5  —
 « Page 4 Contents Page 6 » 
 
Copyright © 2008 by 3D Software. All rights reserved.
3D Software, P.O. Box 221190, Sacramento CA 95822 USA
www.3DSoftware.com     Contact us
Thursday, 20-Nov-2008 11:53:49 GMT