eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'RaisedNumber':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: RaisedNumber


Inheritance:

   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

Description:


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.


Class protocol:

instance creation
o  fraction: fractionArg exponent: exponentArg
for now...


Instance protocol:

accessing
o  exponent

o  exponent: exponentArg

o  fraction

o  fraction: fractionArg exponent: exponentArg

o  normalize
the fraction should/must always be an integer.
I will not loose any precision.

arithmetic
o  * 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

o  + aNumber
(comment from inherited method)
return the sum of the receiver and the argument, aNumber

o  - aNumber
(comment from inherited method)
return the difference of the receiver and the argument, aNumber

o  / 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
o  < aNumber
(comment from inherited method)
return true, if the argument is greater

o  = 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
o  coerce: aNumber
(comment from inherited method)
convert the argument aNumber into an instance of the receiver's class and return it.

double dispatching
o  differenceFromRaisedNumber: aNumber
compute aNumber - self

o  equalFromRaisedNumber: aNumber
compute aNumber = self

o  lessFromRaisedNumber: aNumber
compute aNumber < self

o  productFromRaisedNumber: aNumber
compute aNumber * self

o  quotientFromRaisedNumber: aNumber
compute aNumber / self

o  sumFromRaisedNumber: aNumber
compute aNumber + self

printing
o  printOn: aStream
(fraction asScaledDecimal:5) printOn:aStream.

queries
o  generality
return the generality value - see ArithmeticValue>>retry:coercing:

Usage example(s):

LargeFloat generality

testing
o  isFinite
(comment from inherited method)
return true, if the receiver is a finite float (not NaN and not +/-INF)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 18:56:45 GMT