PackageDescription: ArbitraryPrecisionFloat
Arbitrary Precision FloatLast published: April 5, 2008 by 'nice'
Defines 1 Classes
Extends 6 Classes
PURPOSE:
Add the ability to do inexact floating point arithmetic with an arbitrary number of bits.
Unlike LimitedPrecisionReal, ArbitraryPrecisionFloat have no limit on exponent (except memory bounds of course).
Thus, there is no overflow or underflow.
WARNING:
Arithmetic is emulated possibly with LargeInteger, and is incredibly slow compared to hardwired IEEE 754 Float/Double.
NOTE:
First implemented in Squeak then ported to VW (as coercing messages might help you guess).
TODO:
implement usual mathematical functions.
INSPIRATION SOURCES:
for mathematical functions, Michael C. Ring MAPM C package, David H. Bailey's MPFUN Fortran package
IMPLEMENTATION NOTES AND FEATURES
The numbers are stored with instance variables mantissa, biasedExponent, nBits
All three are integers, and the number is equal to (mantissa) * (2 raisedTo: biasedExponent).
The sign is stored in the mantissa, not in a separate inst var.
The mantissa needs not being normalized (having mantissa highBit = nBits).
biasedExponent is so called because unbias exponent relates to:
1.nnnnnn... * (2 raisedTo: exponent).
This is the definition of LimitedPrecisionReal>>exponent.
Round to nearest even (like IEEE 754 rounding mode) is done by default.
Other rounding mode COULD be implemented... But i dislike the idea of having a unique global variable setting for that feature.
I would like a per-process, or per namespace, per application or temporarily protected rounding mode switching robust to multi-process.
- like ArbitraryPrecisionFloat roundTowardZeroWhile: [...]
- like Processor activeProcess environmentAt: #ArbitraryPrecisionFloatRoundingMode
- like #{ ArbitraryPrecisionFloatRoundingMode } valueOrDo: [Processor activeProcess environmentAt: #ArbitraryPrecisionFloatRoundingMode].
AUTHOR:
nicolas cellier , any question, remarks, etc... go to this email.
LICENSE: (MIT)
Copyright (c) <2006>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.