eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ArithmeticValue':

Home

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

Class: ArithmeticValue


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--ArithmeticValue
         |
         +--MeasurementValue
         |
         +--Number
         |
         +--Point

Package:
stx:libbasic
Category:
Magnitude-Numbers
Version:
rev: 1.220 date: 2024/01/09 14:46:20
user: cg
file: ArithmeticValue.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


ArithmeticValue is an abstract superclass for all things responding to
arithmetic messages. It was inserted into the hierarchy, to allow objects
like matrices, functions etc. to share the arithmetic methods defined here.

Notice, that what used to be signals are now exception classes - the class
variables and signal accessors remain here for backward compatibility.

[class variables:]
    ArithmeticSignal        <Error>         parent of all arithmetic signals
                                            (never raised itself)
                                            New: now a reference to ArithmeticError

    DomainErrorSignal       <Error>         raised upon float errors
                                            (for example range in trigonometric)
                                            New: now a reference to DomainError; no longer a classVar

    DivisionByZeroSignal    <Error>         raised when division by 0 is attempted
                                            New: now a reference to ZeroDivide

    OverflowSignal          <Error>         raised on overflow/underflow conditions
    UnderflowSignal                         in float arithmetic.
                                            Notice: some OperatingSystems do not
                                            provide enough information for ST/X to
                                            extract the real reason for the floatException
                                            thus raising DomainErrorSignal in these cases.

copyright

COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

Compatibility-VW
o  nan
VW compatibility

Signal constants
o  arithmeticSignal
return the parent of all arithmetic signals.
This now returns ArithmeticError (class based exception)
and this method is only provided for portability
(old Smalltalk versions used a signal instance here).
You can savely use ArithmeticError directly.

o  coercionErrorSignal
obsolete

o  divisionByZeroSignal
return the signal which is raised on division by zero.
No longer used - we now have the class based ZeroDivide exception.
This method is kept for backward compatibility.

o  domainErrorSignal
return the signal which is raised on some math errors,
when the argument is outside the legal domain.
(such as arcSin of 2 etc.)
This now returns DomainError (class based exception)
and this method is only provided for portability
(old Smalltalk versions used a signal instance here).
You can savely use DomainError directly.

o  imaginaryResultSignal
return the signal which is raised when an imaginary result would be created
(such as when taking the sqrt of a negative number).
This error can be handled by wrapping the computation inside a trapImaginary
block; then, a complex result is generated.

o  infiniteResultSignal
return the signal which is raised when an infinite result would be created.
This is a subclass of DomainError.
(such as when taking the logarithm of zero)

o  operationNotPossibleSignal

o  overflowSignal
return the signal which is raised on overflow conditions (in floats).
Attention: currently not raised on all architectures; some return NaN

o  rangeErrorSignal
return the parent of the overflow/underflow signals.
This now returns RangeError (class based exception)
and this method is only provided for portability
(old Smalltalk versions used a signal instance here).
You can savely use RangeError directly.

o  undefinedResultSignal

o  underflowSignal
return the signal which is raised on underflow conditions (in floats)
Attention: currently not raised on all architectures; some return zero

o  unorderedSignal
return the signal which is raised when numbers are compared,
for which no ordering is defined (for example: complex numbers).
This now returns UnorderedNumbersError (class based exception)
and this method is only provided for portability
(old Smalltalk versions used a signal instance here).
You can savely use UnorderedNumbersError directly.

class initialization
o  initialize
setup the signals

o  raiseNaNExceptions
this boolean controls if operations with nan should raise an
exception or not.
If not, another nan is returned from such operations.
Does not really work in all situations (need checks in inline C code)

o  raiseNaNExceptions: aBoolean
this boolean controls if operations with nan should raise an
exception or not.
If not, another nan is returned from such operations.
Does not really work in all situations (need checks in inline C code)

o  raiseOutOfRangeExceptions
this boolean controls if float conversions should raise an
exception if the converted value is out of range, or not.
If not, infinity is returned from such operations

o  raiseOutOfRangeExceptions: aBoolean
this boolean controls if float conversions should raise an
exception if the converted value is out of range, or not.
If not, infinity is returned from such operations

coercing & converting
o  coerce: aNumber
convert the argument aNumber into an instance of the receiver (class) and return it.

** This method must be redefined in concrete classes (subclassResponsibility) **

o  generality
return a number giving the receiver's generality.
That number is used to convert one of the arguments in a mixed expression.
The generality has to be defined in subclasses,
such that gen(a) > gen(b) iff, conversion of b into a's class
does not cut precision.
For example, Integer has 40, Float has 80, meaning that if we convert a Float to an Integer,
some precision may be lost.
The generality is used by ArithmeticValue>>retry:coercing:,
which converts the lower-precision number to the higher precision
number's class, when mixed-type arithmetic is performed.

** This method must be redefined in concrete classes (subclassResponsibility) **

constants
o  NaN
return the constant NaN (not a Number).

o  infinity
return something which represents positive infinity.
Warning: do not compare equal against infinities;
instead, check using isFinite or isInfinite

o  negativeInfinity
return something which represents negative infinity.
Warning: do not compare equal against infinities;
instead, check using isFinite or isInfinite

o  one
return something which represents the one element (for my instances).
That is the neutral element for multiplication.

o  positiveInfinity
return something which represents positive infinity.
Warning: do not compare equal against infinities;
instead, check using isFinite or isInfinite

o  powersOfTen
return a table with powers of ten (1..)

Usage example(s):

     Number powersOfTen

o  powersOfTenth
return a table with reciprocals of powers of ten (-1..)

Usage example(s):

     Number powersOfTenth

o  tenRaisedToInteger: int
return a power of ten;
Used often, so we use a table

Usage example(s):

     Number tenRaisedToInteger:-2   
     Number tenRaisedToInteger:-1   
     Number tenRaisedToInteger:1    
     Number tenRaisedToInteger:10    
     Number tenRaisedToInteger:100    

o  unity
return something which represents the unity element (for my instances).
That is the neutral element for multiplication.

o  zero
return something which represents the zero element (for my instances).
That is the neutral element for addition.

Usage example(s):

assume that all of my subclasses know how to add zero

error reporting
o  raise: aSignalSymbolOrErrorClass receiver: someNumber selector: sel arguments: argArray errorString: text
ST-80 compatible signal raising. Provided for PD numeric classes.
aSignalSymbolOrErrorClass is either an Error-subclass, or
the selector which is sent to myself, to retrieve the Exception class / Signal.

Usage example(s):

     Number 
        raise:#domainErrorSignal
        receiver:1.0
        selector:#foo 
        errorString:'foo bar test'

o  raise: anErrorClass receiver: someNumber selector: sel arguments: argArray errorString: text defaultValue: defaultValueIfProceeded
migrating away from ST-80 compatible signal raising.
This provides the default value, if the exception is proceeded
(i.e. for imaginary results).

Usage example(s):

     Number 
        raise:DomainError
        receiver:1.0
        selector:#foo 
        arguments:#()
        errorString:'foo bar test'
        defaultValue:99.99

exception handling
o  trapDomainError: aBlock
evaluate aBlock;
if any DomainError occurs inside, proceed with either the operation's
specified default value or with a NaN.

This allows for regular (failing) code to transparently convert to
some fallBack and behave similar to other systems which do that.

Usage example(s):

     this raises an error:
         0 ln

     this returns NaN:
         Number trapDomainError: [0 ln]

o  trapImaginary: aBlock
evaluate aBlock;
if any ImaginaryResult occurs inside, which would return an imaginary result,
(eg. square root of negative number),
convert the result to a complex number and proceed.

This allows for regular (failing) code to transparently convert to complex.

Usage example(s):

     this raises an error:
         -2 sqrt

     this returns an imaginary result:
         Complex trapImaginary: [-2 sqrt] 

     of course, this one as well:
         -2 asComplex sqrt         

o  trapInfinity: aBlock
evaluate aBlock;
if any DomainError occurs inside, which would return an infinite result,
(eg. ln of zero),
convert the result to infinity and proceed.

This allows for regular (failing) code to transparently convert to infinity and behave
similar to other systems which do that.

Usage example(s):

     this raises an error:
         0 ln

     this returns an imaginary result:
         Number trapInfinity: [0 ln]

o  trapOverflow: aBlock
evaluate aBlock;
if an Overflow occurs inside, return INF and proceed.

Usage example(s):

     this raises an error:
         1000 factorial asShortFloat

     this returns an imaginary result:
         Number trapOverflow: [ 1000 factorial asShortFloat]

o  trapUnderflow: aBlock
evaluate aBlock;
if an Underflow occurs inside, return zero and proceed.

Usage example(s):

     this raises an error:
         1.0 / (1000 factorial)

     this returns an imaginary result:
         Number trapUnderflow: 1.0 / (1000 factorial)]

queries
o  isAbstract
Return if this class is an abstract class.
True is returned for ArithmeticValue here; false for subclasses.
Abstract subclasses must redefine this again.


Instance protocol:

Compatibility-Squeak
o  absSquared
( an extension from the stx:libcompat package )
who needs this???

o  rounded: n
( an extension from the stx:libcompat package )
marked as obsolete by exept MBP at 17-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

JavaScript support
o  js_add: aNumberOrString
( an extension from the stx:libjavascript package )
For JavaScript only:
Generated for +-operator in javascript.

o  js_addFromNumber: aNumber
( an extension from the stx:libjavascript package )
For JavaScript only:
Generated for +-operator in javascript.

o  js_addFromTime: aTime
( an extension from the stx:libjavascript package )
For JavaScript only:
Generated for +-operator in javascript.

arithmetic
o  % aNumber
modulo. Remainder defined in terms of //.
Answer a Number with the same sign as aNumber.

Usage example(s):

9 % 4  -> 1

Usage example(s):

-9 % 4 -> 3

Usage example(s):

9 % -4 -> -3

o  * something
return the product of the receiver and the argument.

** This method must be redefined in concrete classes (subclassResponsibility) **

o  *% percent
multiply the receiver by the given percentage;
i.e. return self * (percent / 100)

Usage example(s):

     200 *% 3    -> 6
     200.0 *% 3  -> 6.0

o  + something
return the sum of the receiver and the argument

** This method must be redefined in concrete classes (subclassResponsibility) **

o  +% percent
add the given percentage of the receiver to the receiver;
i.e. return self + (self * (percent / 100))

Usage example(s):

     200 +% 3 -> 206

o  - something
return the difference of the receiver and the argument

** This method must be redefined in concrete classes (subclassResponsibility) **

o  -% percent
subtract the given percentage of the receiver to the receiver;
i.e. return self - (self * (percent / 100))

Usage example(s):

     200 -% 3 -> 194

o  / something
return the quotient of the receiver and the argument

** This method must be redefined in concrete classes (subclassResponsibility) **

o  // aNumber
return the integer quotient of dividing the receiver by aNumber with
truncation towards negative infinity.

Please be aware of the effect of truncation on negative receivers,
and understand the difference between '//' vs. 'quo:'
and the corresponding '\\' vs. 'rem:'

** This method must be redefined in concrete classes (subclassResponsibility) **

o  \\ something
return the receiver modulo something.
The remainder has the same sign as the argument, something.
The following is always true:
(receiver // something) * something + (receiver \\ something) = receiver

Please be aware of the effect of truncation on negative receivers,
and understand the difference between '//' vs. 'quo:'
and the corresponding '\\' vs. 'rem:'.

Usage example(s):

     1.5 \\ 1      => 0.5
     1.5 \\ 2      => 1.5
     -1.5 \\ 1     => 0.5
     -1.5 \\ 2     => 0.5
     -1.5 \\ -1    => -0.5
     -1.5 \\ -2    => -1.5

     0.9 \\ 0.4    => 0.1
     0.9 \\ -0.4   => -0.3
    -0.9 \\ 0.4    => 0.3
    -0.9 \\ -0.4   => -0.1

o  abs
return the absolute value of the receiver

o  copySignTo: aNumber
Return aNumber with its original magnitude
and same sign as the receiver

Usage example(s):

     -15 copySignTo:1234  -> -1234
     -15 copySignTo:-1234 -> -1234
     15 copySignTo:1234   -> 1234
     15 copySignTo:-1234  -> 1234
     1.0 copySignTo:0.0   -> 0.0 
     -1.0 copySignTo:0.0  -> -0.0
     1 copySignTo:(1/3)   -> (1/3) 
     -1 copySignTo:(1/3)  -> (-1/3)

o  dist: arg
return the distance between the arg and the receiver.

Usage example(s):

     (1%1) dist:(0%0)
     (1@1) dist:(0@0)
     (1) dist:(0)

o  modulusOf: aNumber
return aNumber modulo the receiver.
The remainder has the same sign as something.
Defined for protocol compatibility with ModuloNumber.

o  negated
return the receiver negated

o  percent
1050.0 * 15 percent

o  percentOf: aValue
10 percentOf:1050.0 => 105.0
100 percentOf:1050.0 => 1050.0
200 percentOf:1050.0 => 2100.0

o  permille
1050.0 * 15 permille

o  permilleOf: aValue
10 permilleOf:1050.0 => 10.5
100 permilleOf:1050.0 => 105.0
200 permilleOf:1050.0 => 210.0
1000 permilleOf:1050.0 => 1050.0

o  quo: something
Return the integer quotient of dividing the receiver by the argument
with truncation towards zero.

Please be aware of the effect of truncation on negative receivers,
and understand the difference between '//' vs. 'quo:'
and the corresponding '\\' vs. 'rem:'.

The following is always true:
(receiver quo: aNumber) * aNumber + (receiver rem: aNumber) = receiver
For positive results, this is the same as #//,
for negative results, the remainder is ignored.
I.e.: '9 // 4 = 2' and '-9 // 4 = -3'
in contrast: '9 quo: 4 = 2' and '-9 quo: 4 = -2'

o  reciprocal
return the receiver's reciprocal

Usage example(s):

     (10 + 4i) class unity -> (1+0i)
     (10 + 4i) reciprocal  -> ((5/58)-(1/29)i)
     (4/3) reciprocal  -> (3/4) 
     3 reciprocal  -> (1/3) 
     3.0 reciprocal  -> 0.333333333333333 
     3.0 asLongFloat reciprocal  -> 0.3333333333333333333 
     3.0 asShortFloat reciprocal  -> 0.3333333 

o  rem: something
Return the integer remainder of dividing the receiver by the argument
with truncation towards zero.
The remainder has the same sign as the receiver.
The following is always true:
(receiver quo: something) * something + (receiver rem: something) = receiver

Please be aware of the effect of truncation on negative receivers,
and understand the difference between '//' vs. 'quo:'
and the corresponding '\\' vs. 'rem:'.

o  uncheckedDivide: aNumber
return the quotient of the receiver and the argument, aNumber.
Do not check for divide by zero (return NaN or Infinity).
This operation is provided for emulators of other languages/semantics,
where no exception is raised for these results (i.e. Java).
It is only defined if the argument's type is the same as the receiver's.

arithmetic destructive
o  *= aNumber
Return the product of self multiplied by aNumber.
The receiver MAY, but NEED NOT be changed to contain the product.
So this method must be used as in: 'a := a *= 5'.
This method can be redefined in special datatypes to do optimisations
(especially vectors and matrices)

o  += aNumber
Return the sum of self and aNumber.
The receiver MAY, but NEED NOT be changed to contain the sum.
So this method must be used as in: 'a := a += 5'.
This method can be redefined in special datatypes to do optimisations
(especially vectors and matrices)

o  -= aNumber
Return the difference of self and aNumber.
The receiver MAY, but NEED NOT be changed to contain the difference.
So this method must be used as in: 'a := a -= 5'.
This method can be redefined in special datatypes to do optimisations
(especially vectors and matrices)

o  /= aNumber
Return the quotient of self and aNumber.
The receiver MAY, but NEED NOT be changed to contain the quotient.
So this method must be used as in: 'a := a /= 5'.
This method can be redefined in special datatypes to do optimisations
(especially vectors and matrices)

o  div2
Return the quotient of self divided by 2.
The receiver MAY, but NEED NOT be changed to contain the result.
So this method must be used as in: 'a := a div2'.
This method can be redefined in special datatypes to do optimisations
(especially vectors and matrices)

o  mul2
Return the product of self multiplied by 2.
The receiver MAY, but NEED NOT be changed to contain the result.
So this method must be used as in: 'a := a mul2'.
This method can be redefined in special datatypes to do optimisations
(especially vectors and matrices)

coercing & converting
o  coerce: aNumber
convert the argument aNumber into an instance of the receiver's class and return it.

o  generality
return a number giving the receiver's generality.
That number is used to convert one of the arguments in a mixed expression.
The generality has to be defined in subclasses,
such that gen(a) > gen(b) iff, conversion of b into a's class
does not cut precision.
For example, Integer has 40, Float has 80, meaning that if we convert a Float to an Integer,
some precision may be lost.
The generality is used by ArithmeticValue>>retry:coercing:,
which converts the lower-precision number to the higher precision
number's class, when mixed-type arithmetic is performed.

o  retry: aSymbol coercing: aNumber
arithmetic represented by the binary operator, aSymbol,
could not be performed with the receiver and the argument, aNumber,
because of the differences in representation.
Coerce either the receiver or the argument, depending on which has higher
generality, and try again.
If the operation is compare for same value (=), return false if
the argument is not a Number.
If the generalities are the same, create an error message, since this
means that a subclass has not been fully implemented.

Usage example(s):

self error:'retry:coercing: oops - same generality; retry should not happen'

o  retry: aSymbol coercing: aNumber with: anArgument
arithmetic represented by the binary operator, aSymbol,
could not be performed with the receiver and the argument, aNumber,
because of the differences in representation.
Coerce either the receiver or the argument, depending on which has higher
generality, and try again.
If the operation is compare for same value (=), return false if
the argument is not a Number.
If the generalities are the same, create an error message, since this
means that a subclass has not been fully implemented.

Usage example(s):

self error:'retry:coercing: oops - same generality; retry should not happen'

o  zero
return a zero in my class and my precision

converting
o  as32BitIEEEFloatBytesMSB: msb
2 as32BitIEEEFloatBytesMSB:true
2.0 as32BitIEEEFloatBytesMSB:true

o  as64BitIEEEFloatBytesMSB: msb
2 as64BitIEEEFloatBytesMSB:true
2.0 as64BitIEEEFloatBytesMSB:true

o  asDouble
ST80 compatibility: return a double with receiver's value.
Attention: our floats are the identical to ST80's doubles

o  asFixedDecimal
return a fixedDecimal approximating the receiver's value
to 2 fractional digits

Usage example(s):

     1.234 asFixedDecimal           -> 1.23
     1.234 asScaledDecimal          -> 1.23

     1.238 asFixedDecimal           -> 1.24
     1.238 asScaledDecimal          -> 1.24

     1.234 asFixedDecimal * 2       -> 2.46
     1.234 asScaledDecimal * 2      -> 2.47

o  asFixedDecimal: scale
return a fixedDecimal approximating the receiver's value
to scale fractional digits

Usage example(s):

     1.234 asFixedDecimal:4           -> 1.2340
     1.234 asFixedDecimal:3           -> 1.234
     1.234 asFixedDecimal:2           -> 1.23
     1.234 asFixedDecimal:1           -> 1.2
     1.234 asFixedDecimal:0           -> 1
     123  asFixedDecimal:-1           -> 120
     1234  asFixedDecimal:-1          -> 1230

o  asFixedPoint
marked as obsolete by exept MBP at 18-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  asFixedPoint: scale
marked as obsolete by exept MBP at 18-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  asFixedPointRoundedToScale
marked as obsolete by exept MBP at 18-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  asFixedPointRoundedToScale: scale
marked as obsolete by exept MBP at 18-09-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  asFloat
return a float with same value

** This method must be redefined in concrete classes (subclassResponsibility) **

o  asFloat128
return a quadruple precision float with same value.

o  asFloat16
return a shortFloat with same value.
Does NOT raise an error if the receiver exceeds the float range.

Usage example(s):

    10 asFloat16   -> 10.0
    10.0 asFloat16 -> 10.0

o  asFloat256
return a octuple precision float with same value.

o  asFloat32
return a shortFloat with same value.
Does NOT raise an error if the receiver exceeds the float range.

o  asFloat64
return a double precision float with same value.

o  asFloat80
return an extended precision float (80 bit) with same value.

o  asFloatD
return a double precision float with same value.
Added for ANSI compatibility

o  asFloatE
return a single precision float with same value.
Added for ANSI compatibility

o  asFloatQ
return an extended precision float with same value.
Notice that longFloats as returned here may or may not provide more
precision than a double - depending on the machine's CPU
(and usually do not provide quad the number of bits of a float)
Added for ANSI compatibility

o  asFloatQD
return a quad double precision float with same value.

o  asFraction
return a fraction with same value

** This method must be redefined in concrete classes (subclassResponsibility) **

o  asInteger
return an integer with same value - might truncate

o  asLargeFloat
return a largeFloat with same value

o  asLimitedPrecisionReal
return a float of any precision with same value

o  asLongFloat
return a longFloat with same value

o  asOctaFloat
( an extension from the stx:libbasic2 package )
return an octaFloat with same value

o  asQDouble
( an extension from the stx:libbasic2 package )
return a QDouble with same value

Usage example(s):

     123 asQDouble
     (Fraction basicNew setNumerator:246 denominator:2) asQDouble
     123 asLongFloat asQDouble
     123 asLargeFloat asQDouble

o  asQuadFloat
( an extension from the stx:libbasic2 package )
return a quadFloat with same value

o  asScaledDecimal
return the receiver as asScaledDecimal number.
Here, a default scale (2) is set.
Q: what should the scale be here ?

Usage example(s):

     0.3 asScaledDecimal              => 0.30
     0.5 asScaledDecimal              => 0.50
     (1/5) asFloat asScaledDecimal    => 0.20
     (1/3) asFloat asScaledDecimal    => 0.33
     (2/3) asFloat asScaledDecimal    => 0.67
     (2/3) asFloat asScaledDecimal:5  => 0.66667
     (1/8) asFloat asScaledDecimal    => 0.13
     (1/10) asScaledDecimal           => 0.10
     3.14159 asScaledDecimal          => 3.14
     3.14159 asScaledDecimal:3        => 3.142
     3.14159 asScaledDecimal:4        => 3.1416
     3.14159 asScaledDecimal:5        => 3.14159
     3.14159 asScaledDecimal:6        => 3.141590
     0.0000001 asScaledDecimal        => 0.00
     0.0000001 asScaledDecimal        => 0.00

o  asScaledDecimal: scale
return a scaledDecimal approximating the receiver's value

Usage example(s):

^ (self roundTo:(1.0 / 10 raisedTo:scale+1)) asFraction asScaledDecimal:scale 

Usage example(s):

     1.234 asScaledDecimal:4           => 1.2340
     1.234 asScaledDecimal:3           => 1.234
     1.234 asScaledDecimal:2           => 1.23
     1.234 asScaledDecimal:1           => 1.2
     1.234 asScaledDecimal:0           => 1
     1.2345 asScaledDecimal:4          => 1.2345
     1.2346 asScaledDecimal:3          => 1.235
     1.2345 asScaledDecimal:3          => 1.235

     1.8   asScaledDecimal:0           => 2
     (2/3) asFloat asScaledDecimal     => 0.67
     (2/3) asFloat asScaledDecimal:5   => 0.66667
     (2/3) asFloat asScaledDecimal:8   => 0.66666667

o  asScaledDecimalRoundedToScale
return the receiver as scaled decimal number,
rounded to its default scale (2).

Usage example(s):

     0.3 asScaledDecimal
     0.5 asScaledDecimal
     (2/3) asFloat asScaledDecimal
     (1/8) asFloat asScaledDecimal
     3.14159 asScaledDecimal

     0.3 asScaledDecimalRoundedToScale
     0.5 asScaledDecimalRoundedToScale
     (2/3) asFloat asScaledDecimalRoundedToScale
     (1/8) asFloat asScaledDecimalRoundedToScale
     3.14159 asScaledDecimalRoundedToScale

o  asScaledDecimalRoundedToScale: scale
return the receiver as scaled decimal number with the given
number of post-decimal-digits, rounded to the given scale

Usage example(s):

     3.14159 asScaledDecimalRoundedToScale:1
     3.14159 asScaledDecimalRoundedToScale:2
     3.14159 asScaledDecimalRoundedToScale:3    -> 3.142
     3.14159 asScaledDecimalRoundedToScale:4    -> 3.1416

     3.14159 asScaledDecimalTruncatedToScale:3  -> 3.141
     3.14159 asScaledDecimalTruncatedToScale:4  -> 3.1415

o  asScaledDecimalTruncatedToScale
return the receiver as scaled decimal number,
truncated to its default scale (2).

Usage example(s):

     0.3 asScaledDecimal
     0.5 asScaledDecimal
     (2/3) asFloat asScaledDecimal
     (1/8) asFloat asScaledDecimal
     3.14159 asScaledDecimal

     0.3 asScaledDecimalRoundedToScale
     0.5 asScaledDecimalRoundedToScale
     (2/3) asFloat asScaledDecimalRoundedToScale     -> 0.67
     (2/3) asFloat asScaledDecimalTruncatedToScale   -> 0.66
     (1/8) asFloat asScaledDecimalRoundedToScale     -> 0.13
     (1/8) asFloat asScaledDecimalTruncatedToScale   -> 0.12
     3.14159 asScaledDecimalRoundedToScale

o  asScaledDecimalTruncatedToScale: scale
return the receiver as scaled decimal number with the given
number of post-decimal-digits, truncated to the given scale

Usage example(s):

     3.14159 asScaledDecimalTruncatedToScale:1  -> 3.1
     3.14159 asScaledDecimalTruncatedToScale:2  -> 3.14
     3.14159 asScaledDecimalTruncatedToScale:3  -> 3.141
     3.14159 asScaledDecimalTruncatedToScale:4  -> 3.1415

     3.14159 asScaledDecimalRoundedToScale:3  -> 3.142
     3.14159 asScaledDecimalRoundedToScale:4  -> 3.1416

o  asShortFloat
return a shortFloat with same value.
Does NOT raise an error if the receiver exceeds the float range.

o  degreesToRadians
interpreting the receiver as degrees, return the radians

o  radiansToDegrees
interpreting the receiver as radians, return the degrees

double dispatching
o  bitAndFromInteger: anInteger
anInteger does not know how to do bitAnd: with the receiver -
retry the operation by coercing to Integer

o  bitOrFromInteger: anInteger
anInteger does not know how to do bitOr: with the receiver -
retry the operation by coercing to Integer

o  bitXorFromInteger: anInteger
anInteger does not know how to do bitXor: with the receiver -
retry the operation by coercing to Integer

o  differenceFromComplex: aComplex
aComplex does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromFloat: aFloat
aFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromFraction: aFraction
aFraction does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromInteger: anInteger
anInteger does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromLargeFloat: aLargeFloat
aLargeFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromLongFloat: aLongFloat
aLongFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromNumber: aNumber
aNumber does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromScaledDecimal: aScaledDecimal
aScaledDecimal does not know how to subtract the receiver -
Return true if aScaledDecimal - self.
retry the operation by coercing to higher generality

o  differenceFromShortFloat: aShortFloat
aShortFloat does not know how to subtract the receiver -
retry the operation by coercing to higher generality

o  differenceFromTimeDuration: aTimeDuration
aTimeDuration does not know how to subtract the receiver;
but I know, interpreting the receiver as seconds

o  equalFromComplex: aComplex
aComplex does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromFloat: aFloat
aFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromFraction: aFraction
aFraction does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to compare against by the receiver -
retry the operation by coercing to higher generality

o  equalFromInteger: anInteger
anInteger does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromLargeFloat: aLargeFloat
aLargeFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromLongFloat: aLongFloat
aLongFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromNumber: aNumber
aNumber does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromScaledDecimal: aScaledDecimal
aScaledDecimal does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromShortFloat: aShortFloat
aShortFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  integerQuotientFromInteger: anInteger
anInteger does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  isAlmostEqualToFromFloat: aFloat nEpsilon: nE
aFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  isAlmostEqualToFromLargeFloat: aLargeFloat nEpsilon: nE
aLargeFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  isAlmostEqualToFromLongFloat: aLongFloat nEpsilon: nE
aLongFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  isAlmostEqualToFromOctaFloat: anOctaFloat nEpsilon: nE
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  isAlmostEqualToFromQuadFloat: aQuadFloat nEpsilon: nE
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  isAlmostEqualToFromShortFloat: aShortFloat nEpsilon: nE
aShortFloat does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  lessFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to compare to the receiver -
Return true if aFixedDecimal < self.
retry the operation by coercing to higher generality

o  lessFromFloat: aFloat
aFloat does not know how to compare to the receiver -
Return true if aFloat < self.
retry the operation by coercing to higher generality

o  lessFromFraction: aFraction
aFraction does not know how to compare to the receiver -
Return true if aFraction < self.
retry the operation by coercing to higher generality

o  lessFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to compare against by the receiver -
retry the operation by coercing to higher generality

o  lessFromInteger: anInteger
anInteger does not know how to compare to the receiver -
Return true if anInteger < self.
retry the operation by coercing to higher generality

o  lessFromLargeFloat: aLargeFloat
aLargeFloat does not know how to compare to the receiver -
Return true if aLargeFloat < self.
retry the operation by coercing to higher generality

o  lessFromLongFloat: aLongFloat
aLongFloat does not know how to compare to the receiver -
Return true if aLongFloat < self.
retry the operation by coercing to higher generality

o  lessFromNumber: aNumber
aNumber does not know how to compare to the receiver -
Return true if aNumber < self.
retry the operation by coercing to higher generality

o  lessFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to compare to the receiver -
Return true if anOctaFloat < self.
retry the operation by coercing to higher generality

o  lessFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to compare to the receiver -
Return true if aQDouble < self.
retry the operation by coercing to higher generality

o  lessFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to compare to the receiver -
Return true if aQuadFloat < self.
retry the operation by coercing to higher generality

o  lessFromRaisedNumber: aNumber
( an extension from the stx:libbasic2 package )
aNumber does not know how to compare to the receiver -
Return true if aNumber < self.
retry the operation by coercing to higher generality

o  lessFromScaledDecimal: aScaledDecimal
aScaledDecimal does not know how to compare to the receiver -
Return true if aScaledDecimal < self.
retry the operation by coercing to higher generality

o  lessFromShortFloat: aShortFloat
aShortFloat does not know how to compare to the receiver -
Return true if aShortFloat < self.
retry the operation by coercing to higher generality

o  moduloFromInteger: anInteger
anInteger does not know how to compute the modulo from the receiver -
retry the operation by coercing to higher generality

o  productFromComplex: aComplex
aComplex does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromFloat: aFloat
aFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromFraction: aFraction
aFraction does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromInteger: anInteger
anInteger does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromLargeFloat: aLargeFloat
aLargeFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromLongFloat: aLongFloat
aLongFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromNumber: aNumber
aNumber does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromScaledDecimal: aScaledDecimal
aScaledDecimal does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromShortFloat: aShortFloat
aShortFloat does not know how to multiply the receiver -
retry the operation by coercing to higher generality

o  productFromTimeDuration: aTimeDuration
return aTimeDuration * self

o  quotientFromComplex: aComplex
aComplex does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromFloat: aFloat
aFloat does not know how to divide by the receiver.
Retry the operation by coercing to higher generality.
Return aFloat / self

o  quotientFromFraction: aFraction
aFraction does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromInteger: anInteger
anInteger does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromLargeFloat: aLargeFloat
aLargeFloat does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromLongFloat: aLongFloat
aLongFloat does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromNumber: aNumber
aNumber does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromScaledDecimal: aScaledDecimal
aScaledDecimal does not know how to divide by the receiver -
Return true if aScaledDecimal / self.
retry the operation by coercing to higher generality

o  quotientFromShortFloat: aShortFloat
aShortFloat does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromTimeDuration: aTimeDuration
return aTimeDuration / self

o  raisedFromFloat: aFloat
aFloat does not know how to be raised to the receiver

o  raisedFromNumber: someNumber
aNumber does not know how to be raised to the receiver
(i.e. how to compute
aNumber ** self
)

o  remainderFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromFloat: aFloat
aFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromLargeFloat: aLargeFloat
aLargeFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromLongFloat: aLongFloat
aLongFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromNumber: aNumber
aNumber does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  remainderFromShortFloat: aShortFloat
aShortFloat does not know how to compute the remainder with the receiver -
retry the operation by coercing to higher generality

o  sumFromComplex: aComplex
aComplex does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromFixedDecimal: aFixedDecimal
( an extension from the stx:libbasic2 package )
aFixedDecimal does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromFloat: aFloat
aFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromFraction: aFraction
aFraction does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromIEEEFloat: anIEEEFloat
( an extension from the stx:libbasic2 package )
anIEEEFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromInteger: anInteger
anInteger does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromLargeFloat: aLargeFloat
aLargeFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromLongFloat: aLongFloat
aLongFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromNumber: aNumber
aNumber does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromOctaFloat: anOctaFloat
( an extension from the stx:libbasic2 package )
anOctaFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromQDouble: aQDouble
( an extension from the stx:libbasic2 package )
aQDouble does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromQuadFloat: aQuadFloat
( an extension from the stx:libbasic2 package )
aQuadFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromScaledDecimal: aScaledDecimal
aScaledDecimal does not know how to add the receiver -
retry the operation by coercing to higher generality

o  sumFromShortFloat: aShortFloat
aShortFloat does not know how to add the receiver -
retry the operation by coercing to higher generality

mathematical functions
o  ** aNumber
Answer the receiver raised to the power of the argument, aNumber.

o  cubed
return receiver ^ 3

o  raisedTo: aNumber
return the receiver raised to aNumber (i.e. self ^ aNumber)

Usage example(s):

     2 raisedTo:16
     2.0 raisedTo:16

     3 raisedTo:4
     10@10 raisedTo:4
     10@10 raisedTo:4.0

o  raisedToInteger: exp
return the receiver raised to exp.
Warning: if the receiver is a float/double,
INF may be returned on overflow.
This may be changed silently to raise an error in future versions.

Usage example(s):

     0x10000000000000000 raisedToInteger:6

     (2 raisedToInteger:216)                ->  105312291668557186697918027683670432318895095400549111254310977536
     (2.0 raisedToInteger:216)              -> 1.05312291668557E+65
     (2.0 asLongFloat) raisedToInteger:216  -> 1.053122916685571867E+65
     (2.0 asShortFloat) raisedToInteger:216 -> inf
     (2.0 asQDouble) raisedToInteger:216

     (2 raisedTo:216)
            -> 105312291668557186697918027683670432318895095400549111254310977536
     (2.0 raisedToInteger:216) asInteger - (2 raisedToInteger:216) 
     (2.0 raisedToInteger:400) asInteger - (2 raisedToInteger:400) 
     (2.0 raisedToInteger:500) asInteger - (2 raisedToInteger:500)  
     (2.0 raisedToInteger:1000) asInteger - (2 raisedToInteger:1000)  
     (2.0 raisedToInteger:2000)  
     (2.0 asLongFloat raisedToInteger:2000) 1.148130695274254524E+602
     (2.0 asLargeFloat raisedToInteger:2000) 
        - (2.0 asLongFloat raisedToInteger:2000)

     (2 raisedToInteger:216) asFloat
     (2 raisedTo:216) asFloat       -> 1.05312E+65

     (2 raisedToInteger:500)
     (2 raisedTo:500)
            -> 3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
     (2 raisedTo:-500)
            -> (1/3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376)
     2 raisedToInteger:10           -> 1024
    -2 raisedToInteger:10           -> 1024
     -2 raisedToInteger:9           -> -512
     10 raisedToInteger:-10         -> (1/10000000000)
     2 raisedToInteger:0            -> 1
     2 raisedToInteger:-1           -> (1/2)

     (10.0 asShortFloat raisedToInteger:1) digitBytes              #[0 0 32 65]      
     (10.0 asShortFloat asIEEEFloat raisedToInteger:1) digitBytes  #[0 0 32 65]
     (10.0 asShortFloat raisedToInteger:2) digitBytes              #[0 0 200 66]       
     (10.0 asShortFloat asIEEEFloat raisedToInteger:2) digitBytes  #[0 0 200 66]

     (10.0 asShortFloat raisedToInteger:-2) digitBytes             #[10 215 35 60]       
     (10.0 asShortFloat asIEEEFloat raisedToInteger:-2) digitBytes #[10 215 35 60]
     (10.0 asShortFloat raisedToInteger:-6) digitBytes             #[189 55 134 53]       
     (10.0 asShortFloat asIEEEFloat raisedToInteger:-6) digitBytes #[189 55 134 53

     (10.0 asShortFloat * 10.0 asShortFloat) digitBytes                         #[0 0 200 66]  
     (10.0 asShortFloat asIEEEFloat * 10.0 asShortFloat asIEEEFloat) digitBytes #[0 0 200 66]                 

     0 raisedToInteger:-1           -> error
     Number trapInfinity:[0 raisedToInteger:-1] -> INF

     Time millisecondsToRun:[
        10000 timesRepeat:[
            (2 raisedToInteger:500)
        ]
     ]

     Time millisecondsToRun:[
        |bigNum|
        bigNum := 2 raisedToInteger:500.
        10 timesRepeat:[
            (bigNum raisedToInteger:500)
        ]
     ]  

o  squared
return receiver * receiver

testing
o  denominator
return the denominator of the receiver

o  even
return true if the receiver is divisible by 2.
This is only defined for whole-numbers (integers).

Usage example(s):

^ self truncated asInteger even

Usage example(s):

     2.4 even  -> error
     Number trapDomainError:[2.4 even]  -> false
     2.0 even  -> true 
     1.0 even  -> false 

o  isComplex
Answer whether the receiver has an imaginary part
(i.e. if it is a complex number). Always false here.

o  isFinite
return true, if the receiver is finite (not NaN and not +/-INF)
i.e. it can be represented as a rational number.
MUST be redefined in meta numbers and numbers which have a
representation for infinities (eg. IEEE floats)

o  isFixedDecimal
( an extension from the stx:libbasic2 package )

o  isFloat128
Answer whether the receiver is a 128bit quadruple precision float.
Always false here.

o  isFloat256
Answer whether the receiver is a 128bit octuple precision float.
Always false here.

o  isFloat32
Answer whether the receiver is a 32bit single precision float.
Always false here.

o  isFloat64
Answer whether the receiver is a 64bit double precision float.
Always false here.

o  isFloat80
Answer whether the receiver is a 80bit extended precision float.
Always false here.

o  isInfinite
return true, if the receiver is an infinite number (+Inf or -Inf).
MUST be redefined in meta numbers and numbers which have a
representation for infinities (eg. IEEE floats)

o  isNaN
return true, if the receiver is an invalid number (NaN - not a number).

o  isNegativeInfinity

o  isNegativeZero
return false - must be redefined by subclasses which can represent a negative zero
(i.e. limitedPrecisionReal classes)

o  isPositiveInfinity

o  isReal
return true, if the receiver is some kind of real number (as opposed to a complex);
false is returned here - the method is only redefined in Number (and Complex).

o  isZero
return true if I represent a zero value (neutral addition element).
MUST be redefined by subclasses which can represent multiple zeros
(i.e. a negative zero, as in IEEE floats)

o  negative
return true if the receiver is less than zero.

o  numerator
return the numerator of the receiver.

o  odd
return true if the receiver is not divisible by 2

o  positive
return true, if the receiver is greater or equal to zero (not negative)

o  respondsToArithmetic
return true, if the receiver responds to arithmetic messages.
This should return true for any object which represents a scalar,
matrix, point, physical value or similar object
which can add, subtract, etc.

o  sign
return the sign of the receiver (-1, 0 or 1)

o  signBit
return my sign bit (0 for positive, 1 for negative).
For compatibility with IEEE floats.

o  strictlyPositive
return true, if the receiver is greater than zero

truncation & rounding
o  ceiling
return the integer nearest the receiver towards positive infinity.

Usage example(s):

     5 ceiling    -> 5
     5.0 ceiling  -> 5
     5.1 ceiling  -> 6
     5.9 ceiling  -> 6
     5.0000001 ceiling  -> 6

     -5 ceiling    -> -5
     -5.0 ceiling  -> -5
     -5.1 ceiling  -> -5
     -5.9 ceiling  -> -5
     -5.0000001 ceiling  -> -5
     -4.9 ceiling        -> -4
     -4.9999999 ceiling  -> -4

o  floor
return the receiver truncated towards negative infinity

o  roundTo: aNumber
return the receiver rounded to the nearest multiple of aNumber

Usage example(s):

     0 roundTo:4  -> 0
     1 roundTo:4  -> 0
     2 roundTo:4  -> 4
     3 roundTo:4  -> 4
     4 roundTo:4
     5 roundTo:4  -> 4
     6 roundTo:4  -> 8
     7 roundTo:4

     1.16 roundTo:0.1  -> 1.2
     1.151 roundTo:0.1 -> 1.2
     1.15 roundTo:0.1  -> 1.1  -- because 1.15 is not an exact float (actually a bit less)
     1.149 roundTo:0.1 -> 1.1
     1.14 roundTo:0.1  -> 1.1

     7.99 roundTo:0.1  -> 8.0 
     7.15 roundTo:0.1  -> 7.2 
     7.149 roundTo:0.1 -> 7.1 

     7.123 roundTo:0.1
     7.523 roundTo:0.1
     7.583 roundTo:0.1 
     7.623 roundTo:0.1
     7.623 roundTo:0.01  -> 7.62
     7.624 roundTo:0.01  -> 7.62
     7.625 roundTo:0.01  -> 7.63
     7.628 roundTo:0.01  -> 7.63

     7.628s3 roundTo:0.1  -> 7.60
     7.628s3 roundTo:0.01 -> 7.63
     7.628s3 roundTo:1    -> 8.0

o  roundToNumberOfDigits: precision
round to precision number of valid digits.
CAVEAT: somewhat clumsy naming; see comment in roundToPrecision

Usage example(s):

     1.2345 roundToNumberOfDigits:2   -> 1.2
     12.345 roundToNumberOfDigits:2   -> 12.0
     123.45 roundToNumberOfDigits:2   -> 120.0
     1234.5 roundToNumberOfDigits:2   -> 1200.0

     3.14159 roundToNumberOfDigits:1  -> 3.0
     3.14159 roundToNumberOfDigits:2  -> 3.1
     3.14159 roundToNumberOfDigits:3  -> 3.14
     3.14159 roundToNumberOfDigits:4  -> 3.142
     3.14159 roundToNumberOfDigits:5  -> 3.1416
     3.14159 roundToNumberOfDigits:6  -> 3.14159

     3.1459 roundToNumberOfDigits:2   -> 3.1

     314159 roundToNumberOfDigits:2   -> 310000
     314159 roundToNumberOfDigits:3   -> 314000
     314159 roundToNumberOfDigits:4   -> 314200
     314159 roundToNumberOfDigits:5   -> 314160
     314159 roundToNumberOfDigits:6   -> 314159
     314159 roundToNumberOfDigits:7   -> 314159

     31459 roundToNumberOfDigits:2    -> 31000

     314159 asFloat roundToNumberOfDigits:2 -> 310000.0
     314159 asFloat roundToNumberOfDigits:4 -> 314200.0
     314159 asFloat roundToNumberOfDigits:5 -> 314160.0
     314159 asFloat roundToNumberOfDigits:6 -> 314159.0
     314159 asFloat roundToNumberOfDigits:7 -> 314159.0

o  roundToPrecision: scalePrecision
round to scalePrecision number of fractional decimal digits.
If the argument is negative, the receiver is rounded to
multiples of a power of 10 (i.e. with -1, to multiples of 10).
CAVEAT: wrong naming; should be called roundToNumberOfFractionalDigits
or similar. Because precision would be the overall number of digits. (sigh)

Usage example(s):

     1.2345 roundToPrecision:2   -> 1.23
     12.345 roundToPrecision:2   -> 12.35
     123.45 roundToPrecision:2   -> 123.45
     1234.5 roundToPrecision:2   -> 1234.5

     3.14159 roundToPrecision:0  -> 3
     3.54159 roundToPrecision:0  -> 4
     3.14159 roundToPrecision:1  -> 3.1
     3.14159 roundToPrecision:2  -> 3.14
     3.14159 roundToPrecision:3  -> 3.142
     3.14159 roundToPrecision:4  -> 3.1416
     3.14159 roundToPrecision:5  -> 3.14159
     3.14159 roundToPrecision:6  -> 3.14159
     3.14159265358979 roundToPrecision:4  => 3.1416 
     3.14159265358979 roundToPrecision:5  => 3.14159   
     3.14159265358979 roundToPrecision:6  => 3.141593  
     3.14159265358979 roundToNumberOfDigits:6  => 3.14159  
     3.14159265358979 roundToNumberOfDigits:5  => 3.1416  
     3.14159265358979 roundToNumberOfDigits:4  => 3.142 
     31.4159265358979 roundToNumberOfDigits:4  => 31.42 

     3.1459 roundToPrecision:2   -> 3.15

     314159 roundToPrecision:2   -> 314159
     31459 roundToPrecision:2    -> 31459

     31459 roundToPrecision:-1 -> 31460  
     31459 roundToPrecision:-2 -> 31500 
     31459 roundToPrecision:-3 -> 31000 
     31459 roundToPrecision:-4 -> 30000 
     35459 roundToPrecision:-4 -> 40000 

     31459 roundToPrecision:-5 -> 0 
     51459 roundToPrecision:-5 -> 100000 
     61459 roundToPrecision:-5 -> 100000 

o  roundUpTo: aNumber
return the receiver rounded up to the next multiple of aNumber

Usage example(s):

     0 roundUpTo:4  -> 0
     1 roundUpTo:4  -> 4
     2 roundUpTo:4  -> 4
     3 roundUpTo:4  -> 4
     4 roundUpTo:4  -> 4
     5 roundUpTo:4  -> 8
     6 roundUpTo:4
     7 roundUpTo:4
     8 roundUpTo:4
     (3@4) roundUpTo:8
     (3@4) roundUpTo:(5 @ 4)
     (3@3) roundUpTo:(5 @ 4) 

o  rounded
return the receiver rounded to the nearest integer

o  roundedToScale
I am already rounded to my scale, so this is a noop.
This is provided for protocol compatibility with ScaledDecimals

o  truncateTo: aNumber
return the receiver truncated (towards zero) to multiples of aNumber;
bad name; should be called truncatedTo:aNumber

Usage example(s):

     truncate to multiples of 4 
        123.456 truncateTo:4      => 120
        124.456 truncateTo:4      => 124
        125.456 truncateTo:4      => 124
     truncate to multiples of 2 
        122.456 truncateTo:2
        123.456 truncateTo:2
        124.456 truncateTo:2
     normal truncate
        123.456 truncateTo:1
        124.456 truncateTo:1
     truncate to decimal digits    
        123.456 truncateTo:0.1    => 123.4
        123.987 truncateTo:0.1    => 123.9
        123.456 truncateTo:0.01   => 123.45
        123.456 truncateTo:0.001  => 123.456

o  truncated
return the receiver truncated towards zero



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 02:40:45 GMT