
Class: ArithmeticValue
Object

+Magnitude

+ArithmeticValue

+Number

+Point
 Package:
 stx:libbasic
 Category:
 MagnitudeNumbers
 Version:
 rev:
1.137
date: 2019/06/09 11:21:39
 user: cg
 file: ArithmeticValue.st directory: libbasic
 module: stx stcclassLibrary: libbasic
 Author:
 Claus Gittinger
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.
Number
Signal constants

arithmeticSignal

return the parent of all arithmetic signals

coercionErrorSignal


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.

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

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.

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)

operationNotPossibleSignal


overflowSignal

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

rangeErrorSignal

return the parent of the overflow/underflow signals

undefinedResultSignal


underflowSignal

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

unorderedSignal

return the signal which is raised when numbers are compared,
for which no ordering is defined (for example: complex numbers)
class initialization

initialize

setup the signals
coercing & converting

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

NaN

return the constant NaN (not a Number).

infinity

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

nan

VW compatibility

negativeInfinity

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

positiveInfinity

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

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

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

raise: aSignalSymbolOrErrorClass receiver: someNumber selector: sel arguments: argArray errorString: text

ST80 compatible signal raising. Provided for PD numeric classes.
aSignalSymbolOrErrorClass is either an Errorsubclass, 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

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


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]


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]


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

isAbstract

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

js_add: aNumberOrString
( an extension from the stx:libjavascript package )

For JavaScript only:
Generated for +operator in javascript.

js_addFromNumber: aNumber
( an extension from the stx:libjavascript package )

For JavaScript only:
Generated for +operator in javascript.

js_addFromTime: aTime
( an extension from the stx:libjavascript package )

For JavaScript only:
Generated for +operator in javascript.
arithmetic

* something

return the product of the receiver and the argument.
** This method raises an error  it must be redefined in concrete classes **

+ something

return the sum of the receiver and the argument
** This method raises an error  it must be redefined in concrete classes **

 something

return the difference of the receiver and the argument
** This method raises an error  it must be redefined in concrete classes **

/ something

return the quotient of the receiver and the argument
** This method raises an error  it must be redefined in concrete classes **

// 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 **

\\ 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


abs

return the absolute value of the receiver

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)


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)


modulusOf: aNumber

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

negated

return the receiver negated

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'

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


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:'.

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

*= 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

+= 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

= 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

/= 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

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

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

coerce: aNumber

convert the argument aNumber into an instance of the receiver's class and return it.

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 lowerprecision number to the higher precision
number's class, when mixedtype arithmetic is performed.
** This method raises an error  it must be redefined in concrete classes **

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'


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

as32BitIEEEFloatBytesMSB: msb

2 as32BitIEEEFloatBytesMSB:true
2.0 as32BitIEEEFloatBytesMSB:true

as64BitIEEEFloatBytesMSB: msb

2 as64BitIEEEFloatBytesMSB:true
2.0 as64BitIEEEFloatBytesMSB:true

asDouble

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

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


asFixedPoint: scale

return the receiver as fixedPoint number with the given
number of postdecimaldigits.
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


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


asFixedPointRoundedToScale: scale

return the receiver as fixedPoint number with the given
number of postdecimaldigits, rounded to its scale
usage example(s):
3.14159 asFixedPointRoundedToScale:1
3.14159 asFixedPointRoundedToScale:2
3.14159 asFixedPointRoundedToScale:3
3.14159 asFixedPointRoundedToScale:4


asFloat

return a float with same value
** This method raises an error  it must be redefined in concrete classes **

asFloatD

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

asFloatE

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

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

asFloatQD

return a quad double precision float with same value.

asFraction

return a fraction with same value
** This method raises an error  it must be redefined in concrete classes **

asInteger

return an integer with same value  might truncate

asLargeFloat

return a largeFloat with same value

asLimitedPrecisionReal

return a float of any precision with same value

asLongFloat

return a longFloat with same value

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


asQuadFloat

return a quadFloat with same value

asScaledDecimal: scale

return a fixedPoint approximating the receiver's value
usage example(s):

asShortFloat

return a shortFloat with same value

degreesToRadians

interpreting the receiver as degrees, return the radians

radiansToDegrees

interpreting the receiver as radians, return the degrees
double dispatching

bitAndFromInteger: anInteger

anInteger does not know how to do bitAnd: with the receiver 
retry the operation by coercing to Integer

bitOrFromInteger: anInteger

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

bitXorFromInteger: anInteger

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

differenceFromComplex: aComplex

aComplex does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromFixedPoint: aFixedPoint

aFixedPoint does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromFloat: aFloat

aFloat does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromFraction: aFraction

aFraction does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromInteger: anInteger

anInteger does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromLargeFloat: aLargeFloat

aLargeFloat does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromLongFloat: aLongFloat

aLongFloat does not know how to subtract the receiver 
retry the operation by coercing to higher generality

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

differenceFromQuadFloat: aQuadFloat

aQuadFloat does not know how to subtract the receiver 
retry the operation by coercing to higher generality

differenceFromShortFloat: aShortFloat

aShortFloat does not know how to subtract the receiver 
retry the operation by coercing to higher generality

equalFromComplex: aComplex

aComplex does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromFixedPoint: aFixedPoint

aFixedPoint does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromFloat: aFloat

aFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromFraction: aFraction

aFraction does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromInteger: anInteger

anInteger does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromLargeFloat: aLargeFloat

aLargeFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromLongFloat: aLongFloat

aLongFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

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

equalFromQuadFloat: aQuadFloat

aQuadFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

equalFromShortFloat: aShortFloat

aShortFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

integerQuotientFromInteger: anInteger

anInteger does not know how to divide by the receiver 
retry the operation by coercing to higher generality

isAlmostEqualToFromFloat: aFloat nEpsilon: nE

aFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

isAlmostEqualToFromLargeFloat: aLargeFloat nEpsilon: nE

aLargeFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

isAlmostEqualToFromLongFloat: aLongFloat nEpsilon: nE

aLongFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

isAlmostEqualToFromQuadFloat: aQuadFloat nEpsilon: nE

aQuadFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

isAlmostEqualToFromShortFloat: aShortFloat nEpsilon: nE

aShortFloat does not know how to compare to the receiver 
retry the operation by coercing to higher generality

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

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

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

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

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

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

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

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

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

moduloFromInteger: anInteger

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

productFromComplex: aComplex

aComplex does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromFixedPoint: aFixedPoint

aFixedPoint does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromFloat: aFloat

aFloat does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromFraction: aFraction

aFraction does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromInteger: anInteger

anInteger does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromLargeFloat: aLargeFloat

aLargeFloat does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromLongFloat: aLongFloat

aLongFloat does not know how to multiply the receiver 
retry the operation by coercing to higher generality

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

productFromQuadFloat: aQuadFloat

aQuadFloat does not know how to multiply the receiver 
retry the operation by coercing to higher generality

productFromShortFloat: aShortFloat

aShortFloat does not know how to multiply the receiver 
retry the operation by coercing to higher generality

quotientFromComplex: aComplex

aComplex does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromFixedPoint: aFixedPoint

aFixedPoint does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromFloat: aFloat

aFloat does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromFraction: aFraction

aFraction does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromInteger: aQDouble

aQDouble does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromLargeFloat: aLargeFloat

aLargeFloat does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromLongFloat: aLongFloat

aLongFloat does not know how to divide by the receiver 
retry the operation by coercing to higher generality

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

quotientFromQuadFloat: aQuadFloat

aQuadFloat does not know how to divide by the receiver 
retry the operation by coercing to higher generality

quotientFromShortFloat: aShortFloat

aShortFloat does not know how to divide by the receiver 
retry the operation by coercing to higher generality

raisedFromFloat: aFloat

aFloat does not know how to be raised to the receiver

raisedFromNumber: aNumber

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

remainderFromFloat: aFloat

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

remainderFromLargeFloat: aLargeFloat

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

remainderFromLongFloat: aLongFloat

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

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

remainderFromQuadFloat: aQuadFloat

aQuadFloat does not know how to compute the remainder with the receiver 
retry the operation by coercing to higher generality

remainderFromShortFloat: aShortFloat

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

sumFromComplex: aComplex

aComplex does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromFixedPoint: aFixedPoint

aFixedPoint does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromFloat: aFloat

aFloat does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromFraction: aFraction

aFraction does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromInteger: anInteger

anInteger does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromLargeFloat: aLargeFloat

aLargeFloat does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromLongFloat: aLongFloat

aLongFloat does not know how to add the receiver 
retry the operation by coercing to higher generality

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

sumFromQuadFloat: aQuadFloat

aQuadFloat does not know how to add the receiver 
retry the operation by coercing to higher generality

sumFromShortFloat: aShortFloat

aShortFloat does not know how to add the receiver 
retry the operation by coercing to higher generality
mathematical functions

** aNumber

Answer the receiver raised to the power of the argument, aNumber.

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.

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


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


squared

return receiver * receiver
queries

respondsToArithmetic

return true, if the receiver responds to arithmetic messages
testing

denominator

return the denominator of the receiver

even

return true if the receiver is divisible by 2.
This is only defined for wholenumbers (integers).
usage example(s):
^ self truncated asInteger even

usage example(s):

isComplex

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

isFinite

return true, if the receiver is finite
i.e. it can be represented as a rational number.

isInfinite


isNegativeInfinity


isNegativeZero

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

isPositiveInfinity


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

isZero

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

negative

return true if the receiver is less than zero.

numerator

return the numerator of the receiver.

odd

return true if the receiver is not divisible by 2

positive

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

sign

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

strictlyPositive

return true, if the receiver is greater than zero
truncation & rounding

ceiling

return the integer nearest the receiver towards positive infinity.

floor

return the receiver truncated towards negative infinity

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


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)


rounded

return the integer nearest the receiver

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


truncated

return the receiver truncated towards zero
