|  3DSoftware.com > Programming > Floating Point > Page 6 |
|
Floating Point Numbers
Page 6
Wide Floating Point Addition To add two WideFloat numbers, if they have the same exponent, simply add the corresponding digit packets. If they are not the same exponents, the number with the lesser exponent is right shifted (digit-wise by the difference of the exponents) into new digit packets, and then the corresponding digit packets are added together. Any digit packet that is shifted out of range is either discarded (truncated) or used for rounding. Carrying is then performed beginning from the least significant digit packet. If the most significant digit packet generates a |
|
Subtraction
Subtraction is the same as for WideInteger, but with borrowing in the opposite direction, and with shifting of digit packets if the exponents are different. If the operands have different signs, do addition instead of subtraction. Likewise, to perform addition of operands with different signs, perform subtraction. Addition and subtraction are unsigned operations in this implementation. |
|
Truncation and Rounding
Truncation can cause gradual downward drift of Rounding can involve increasing the width of Rounding if the guard bit and lowest significand bit are both set, and the sticky bit is clear, is called round to even. |
|
|
Goldberg, D., 2007, Computer Arithmetic, Appendix I (on disk) in
Hennessy & Patterson,
Computer Architecture: A Quantitative Approach 4th ed.,
|
|
|
Antia, H.M., 2002,
Numerical Methods for Scientists and Engineers
|
|
|
Patterson, D.A., and Hennessy, J.L., 2005,
Computer Organization and Design: The Hardware/Software Interface
|
|
|
Goldberg, 2007,
|
|
|
Goldberg, D.,
What Every Computer Scientist Should Know about Floating-Point Arithmetic,
|
| 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 14:23:39 GMT |