3DSoftware.com > Programming > Floating Point > Page 7
Floating Point Numbers  Page 7
 
Wide Floating Point
 
Multiplication
 
Multiplication of WideFloat numbers consists of adding the exponents and multiplying the significands.
 
Multiplication of significands is like WideInteger multiplication, but with carrying in the opposite direction. Carrying will be from high multiplication to low multiplication.
 
Multiplication with Truncation
 
Multiplication of two WideFloat numbers, A and B, each having 6 digit packets, with truncation of the product is accomplished with this polynomial:
 
 AB  =   ( A5B1 + A4B2 + A3B3 + A2B4 + A1B5 )t–6
+ ( A5B0 + A4B1 + A3B2 + A2B3 + A1B4 + A0B5 )t–5
+ ( A4B0 + A3B1 + A2B2 + A1B3 + A0B4 )t–4
+ ( A3B0 + A2B1 + A1B2 + A0B3 )t–3
+ ( A2B0 + A1B1 + A0B2 )t–2
+ ( A1B0 + A0B1 )t–1
+ ( A0B0 )t0
 
t = 230 
An are digit packets of A
Bn are digit packets of B
 
The t–6 coefficient is not used other than to create a carry into the t–5 coefficient. That is the carry from high multiplication. No other high multiplication operations are needed. The factors of the other terms of high multiplication do not need to be compared to zero.
 
The t–5 coefficient creates a carry into the t–4 coefficient, the t–4 coefficient creates a carry into the t–3 coefficient, etc.
 
If the t0 coefficient creates a carry, then that carry becomes a new digit packet, and the least significant digit packet is discarded, and the exponent is incremented.
 
The coefficients are two digit packets wide, and can be split into digit packets before or after carries are propagated.
 
Multiplication with Rounding
 
The same multiplication, to support rounding instead of truncation, is accomplished with this polynomial:
 
 AB  =   ( A5B5 )t–10
+ ( A5B4 + A4B5 )t–9
+ ( A5B3 + A4B4 + A3B5 )t–8
+ ( A5B2 + A4B3 + A3B4 + A2B5 )t–7
+ ( A5B1 + A4B2 + A3B3 + A2B4 + A1B5 )t–6
+ ( A5B0 + A4B1 + A3B2 + A2B3 + A1B4 + A0B5 )t–5
+ ( A4B0 + A3B1 + A2B2 + A1B3 + A0B4 )t–4
+ ( A3B0 + A2B1 + A1B2 + A0B3 )t–3
+ ( A2B0 + A1B1 + A0B2 )t–2
+ ( A1B0 + A0B1 )t–1
+ ( A0B0 )t0
 
 
Carrying is from t–10 to t–9, from t–9 to t–8, etc.
 
You can do two multiplications at once with PMULUDQ. Unsigned additions of 64-bit numbers can be performed with PADDQ. The following table may be useful for organizing simd operations:
 
t0 t–1 t–2 t–3 t–4 t–5 t–6 t–7 t–8 t–9 t–10
  
  
  
  
  
A0B0
  
  
  
  
A1B0
A0B1
  
  
  
A2B0
A1B1
A0B2
  
  
A3B0
A2B1
A1B2
A0B3
  
A4B0
A3B1
A2B2
A1B3
A0B4
A5B0
A4B1
A3B2
A2B3
A1B4
A0B5
A5B1
A4B2
A3B3
A2B4
A1B5
A5B2
A4B3
A3B4
A2B5
A5B3
A4B4
A3B5
A5B4
A4B5
A5B5
 
If a new digit is created (if t0 has a carry-out), then increment the exponent and shift the digit packets one position so that the new digit is the only digit to the left of the radix point.
 
—  Page 7  —
 « Page 6 Contents Page 8 » 
 
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 13:16:06 GMT