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
         |
         +--Number
         |
         +--Point

Package:
stx:libbasic
Category:
Magnitude-Numbers
Version:
rev: 1.137 date: 2019/06/09 11:21:39
user: cg
file: ArithmeticValue.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

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.


Related information:

    Number

Class protocol:

Signal constants
o  arithmeticSignal
return the parent of all arithmetic signals

o  coercionErrorSignal

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.)

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

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)

class initialization
o  initialize
setup the signals

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

** This method raises an error - it must be redefined in concrete classes **

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  nan
VW compatibility

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

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

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

** This method raises an error - it must be redefined in concrete classes **

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

** This method raises an error - it must be redefined in concrete classes **

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'

exception handling
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:

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  * something
return the product of the receiver and the argument.

** This method raises an error - it must be redefined in concrete classes **

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

** This method raises an error - it must be redefined in concrete classes **

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

** This method raises an error - it must be redefined in concrete classes **

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

** This method raises an error - it must be redefined in concrete classes **

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 raises an error - it must be redefined in concrete classes **

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):

     0.9 \\ 0.4
     0.9 \\ -0.4
    -0.9 \\ 0.4
    -0.9 \\ -0.4

o  abs
return the absolute value of the receiver

o  copySignTo: aNumber
Return a number with same magnitude as aNumber and same sign as self

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  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: 'a := a *= 5'.
This method can be redefined for constructed datatypes to do optimisations

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: 'a := a += 5'.
This method can be redefined for constructed datatypes to do optimisations

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: 'a := a -= 5'.
This method can be redefined for constructed datatypes to do optimisations

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: 'a := a /= 5'.
This method can be redefined for constructed datatypes to do optimisations

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: 'a := a div2.
This method can be redefined for constructed datatypes to do optimisations

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: a := a mul2.
This method can be redefined for constructed datatypes to do optimisations

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.

** This method raises an error - it must be redefined in concrete classes **

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'

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  asFixedPoint
return the receiver as fixedPoint number.
Q: what should the scale be here ?

usage example(s):

     0.3 asFixedPoint
     0.5 asFixedPoint
     (1/5) asFloat asFixedPoint
     (1/3) asFloat asFixedPoint
     (2/3) asFloat asFixedPoint
     (1/8) asFloat asFixedPoint
     3.14159 asFixedPoint
     0.0000001 asFraction
     0.0000001 asFixedPoint

o  asFixedPoint: scale
return the receiver as fixedPoint number with the given
number of post-decimal-digits.

usage example(s):

     0.3 asFixedPoint:4
     0.3 asFixedPoint:3
     0.3 asFixedPoint:2
     0.3 asFixedPoint:1
     0.3 asFixedPoint:0

     0.5 asFixedPoint:3
     (1/5) asFloat asFixedPoint:1
     (1/8) asFloat asFixedPoint:1
     1.0 asFixedPoint:2
     3.14159 asFixedPoint:2
     3.14159 asFixedPoint:3
     (3.14159 asFixedPoint:2) asFixedPoint:5

o  asFixedPointRoundedToScale
return the receiver as fixedPoint number, rounded to its scale.

usage example(s):

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

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

o  asFixedPointRoundedToScale: scale
return the receiver as fixedPoint number with the given
number of post-decimal-digits, rounded to its scale

usage example(s):

     3.14159 asFixedPointRoundedToScale:1
     3.14159 asFixedPointRoundedToScale:2
     3.14159 asFixedPointRoundedToScale:3
     3.14159 asFixedPointRoundedToScale:4

o  asFloat
return a float with same value

** This method raises an error - it must be redefined in concrete classes **

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 a quad 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 raises an error - it must be redefined in concrete classes **

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  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
return a quadFloat with same value

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

usage example(s):

     1.234 asScaledDecimal:2

o  asShortFloat
return a shortFloat with same value

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  differenceFromFixedPoint: aFixedPoint
aFixedPoint 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  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  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
aQuadFloat does not know how to subtract the receiver -
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  equalFromComplex: aComplex
aComplex does not know how to compare to the receiver -
retry the operation by coercing to higher generality

o  equalFromFixedPoint: aFixedPoint
aFixedPoint 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  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  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
aQuadFloat 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  isAlmostEqualToFromQuadFloat: aQuadFloat nEpsilon: nE
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  lessFromFixedPoint: aFixedPoint
aFixedPoint does not know how to compare to the receiver -
Return true if aFixedPoint < 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  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  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
aQuadFloat does not know how to compare to the receiver -
Return true if aQuadFloat < 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  productFromFixedPoint: aFixedPoint
aFixedPoint 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  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  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
aQuadFloat 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  quotientFromComplex: aComplex
aComplex does not know how to divide by the receiver -
retry the operation by coercing to higher generality

o  quotientFromFixedPoint: aFixedPoint
aFixedPoint 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

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

o  quotientFromInteger: aQDouble
aQDouble 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  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
aQuadFloat does not know how to divide by the receiver -
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  raisedFromFloat: aFloat
aFloat does not know how to be raised to the receiver

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

o  remainderFromFloat: aFloat
aFloat 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  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
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  sumFromFixedPoint: aFixedPoint
aFixedPoint 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  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  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
aQuadFloat 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  basicRaisedToInteger: exp
return the receiver raised to exp.
Warning: if the receiver is a float/double,
currently INF may be returned on overflow.
This may be changed silently to raise an error in future versions.

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,
currently INF may be returned on overflow.
This may be changed silently to raise an error in future versions.

usage example(s):

     (2.0 raisedToInteger:10000)
     (2 raisedToInteger:10000)
     (2 raisedToInteger:-10000)

     (2.0 raisedToInteger:216)
     (2 raisedToInteger:216)
     (2 raisedTo:216)
            -> 105312291668557186697918027683670432318895095400549111254310977536

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

     (2 raisedToInteger:500)
     (2 raisedTo:500)
            -> 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)

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

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

o  squared
return receiver * receiver

queries
o  respondsToArithmetic
return true, if the receiver responds to arithmetic messages

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
     2.0 even

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
i.e. it can be represented as a rational number.

o  isInfinite

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 false - must be redefined by subclasses which can represent a negative zero
(i.e. limitedPrecisionReal classes)

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  sign
return the sign of the receiver (-1, 0 or 1)

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

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

o  floor
return the receiver truncated towards negative infinity

o  roundTo: aNumber
return the receiver rounded to multiples of aNumber

usage example(s):

     0 roundTo:4
     1 roundTo:4
     2 roundTo:4
     3 roundTo:4
     4 roundTo:4
     5 roundTo:4
     6 roundTo:4
     7 roundTo:4

     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.628 roundTo:0.01 

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

usage example(s):

     0 roundUpTo:4
     1 roundUpTo:4
     2 roundUpTo:4
     3 roundUpTo:4
     4 roundUpTo:4
     5 roundUpTo:4
     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 integer nearest the receiver

o  truncateTo: aNumber
return the receiver truncated to multiples of aNumber

usage example(s):

     truncate to multiples of 4 
        123.456 truncateTo:4
        124.456 truncateTo:4
     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.987 truncateTo:0.1
        123.456 truncateTo:0.01

o  truncated
return the receiver truncated towards zero



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 28 Mar 2024 19:15:31 GMT