|
Class: RaisedNumber
Object
|
+--Magnitude
|
+--ArithmeticValue
|
+--Number
|
+--LimitedPrecisionReal
|
+--RaisedNumber
- Package:
- stx:libbasic2
- Category:
- Magnitude-Numbers
- Version:
- rev:
1.3
date: 2024/01/15 08:47:44
- user: cg
- file: RaisedNumber.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
This is a helper class to represent huge numbers.
Experimental and unfinished.
Do NOT use - use ScaledDecimals or FixedDecimals.
I represent numbers as
fraction * 10^exponent
(in contrast to LargeFloat, which uses base2).
I.e. should probably be renamed to DecimalNumber.
instance creation
-
fraction: fractionArg exponent: exponentArg
-
for now...
accessing
-
exponent
-
-
exponent: exponentArg
-
-
fraction
-
-
fraction: fractionArg exponent: exponentArg
-
-
normalize
-
the fraction should/must always be an integer.
I will not loose any precision.
arithmetic
-
* aNumber
-
2e20 * 4e30 => 8e+50
(RaisedNumber fraction:2 exponent:20) * (RaisedNumber fraction:4 exponent:30) => 8e+50
5e20 * 2e19 => 1e+40
(RaisedNumber fraction:5 exponent:20) * (RaisedNumber fraction:2 exponent:19) => 1e+40
-
+ aNumber
-
(comment from inherited method)
return the sum of the receiver and the argument, aNumber
-
- aNumber
-
(comment from inherited method)
return the difference of the receiver and the argument, aNumber
-
/ aNumber
-
(10 ** 20) / (10 ** 30)
(RaisedNumber fraction:1 exponent:20) / (RaisedNumber fraction:1 exponent:30)
(10 ** 8000) / (10 ** 9000)
(RaisedNumber fraction:1 exponent:8000) / (RaisedNumber fraction:1 exponent:9000)
Usage example(s):
Modified (comment): / 15-01-2022 / 01:03:34 / cg
|
comparing
-
< aNumber
-
(comment from inherited method)
return true, if the argument is greater
-
= aNumber
-
(comment from inherited method)
Compare the receiver with the argument and return true if the
receiver is equal to the argument. Otherwise return false.
converting
-
coerce: aNumber
-
(comment from inherited method)
convert the argument aNumber into an instance of the receiver's class and return it.
double dispatching
-
differenceFromRaisedNumber: aNumber
-
compute aNumber - self
-
equalFromRaisedNumber: aNumber
-
compute aNumber = self
-
lessFromRaisedNumber: aNumber
-
compute aNumber < self
-
productFromRaisedNumber: aNumber
-
compute aNumber * self
-
quotientFromRaisedNumber: aNumber
-
compute aNumber / self
-
sumFromRaisedNumber: aNumber
-
compute aNumber + self
printing
-
printOn: aStream
-
(fraction asScaledDecimal:5) printOn:aStream.
queries
-
generality
-
return the generality value - see ArithmeticValue>>retry:coercing:
Usage example(s):
testing
-
isFinite
-
(comment from inherited method)
return true, if the receiver is a finite float (not NaN and not +/-INF)
|