This is a partial port of the Squeak/Smalltalk Number class.
Class Number holds the most general methods for dealing with numbers. Subclasses Float, Fraction, and Integer, and their subclasses, provide concrete representations of a numeric quantity.
All of Number's subclasses participate in a simple type coercion mechanism that supports mixed-mode arithmetic and comparisons. It works as follows: If self<typeA> op: arg<typeB> fails because of incompatible types, then it is retried in the following guise: (arg adaptTypeA: self) op: arg adaptToTypeA. This gives the arg of typeB an opportunity to resolve the incompatibility, knowing exactly what two types are involved. If self is more general, then arg will be converted, and viceVersa. This mechanism is extensible to any new number classes that one might wish to add to Squeak. The only requirement is that every subclass of Number must support a pair of conversion methods specific to each of the other subclasses of Number.
To create new Number subclass instances, use one of the static instance-creation methods, NOT 'new Integer', etc:
Located in /harmoni/core/Primitives/Numbers/Number.class.php (line 46)
SObject | --Magnitude | --Number
Answer a Number that is the absolute value (positive magnitude) of the receiver.
Answer a double-precision floating-point number approximating the receiver.
Answer a floating-point number approximating the receiver.
Answer an Integer nearest the receiver toward zero.
Answer the integer nearest the receiver toward positive infinity.
Answer the result of dividing the receiver and aNumber.
Answer the integer nearest the receiver toward negative infinity.
Answer a new object with the value specified
Answer whether the receiver and the argument are the same.
If = is redefined in any subclass, consider also redefining the message hash.
Test if this is less than aMagnitude.
Integer quotient defined by division with truncation toward negative infinity. 9//4 = 2, -9//4 = -3. -0.9//0.4 = -3. Modulo (\\) answers the remainder from this division.
modulo. Remainder defined in terms of the integerQutient (\\). Answer a Number with the same sign as aNumber.
e.g. 9\\4 = 1, -9\\4 = 3, 9\\-4 = -3, 0.9\\0.4 = 0.1.
Answer the result of multiplying the receiver and aNumber.
Answer the sum of the receiver and aNumber.
Answer a String whose characters are a description of the receiver.
Override this method as needed to provide a better representation
Answer 1 divided by the receiver. Create an error notification if the receiver is 0.
Remainder defined in terms of quo:. Answer a Number with the same sign as self. e.g. 9 rem: 4 = 1, -9 rem: 4 = -1. 0.9 rem: 0.4 = 0.1.
Integer quotient defined by division with truncation toward zero.
-9 quo: 4 = -2 -0.9 quo: 0.4 = -2. rem: answers the remainder from this division.
Answer the PHP primitive value of the reciever.
Answer a new object with the value specified
Answer a new object with the value zero
Set the internal value to a PHP primitive.
Inherited From Magnitude
Magnitude::isBetween()
Magnitude::isEqualTo()
Magnitude::isGreaterThan()
Magnitude::isGreaterThanOrEqualTo()
Magnitude::isLessThan()
Magnitude::isLessThanOrEqualTo()
Magnitude::max()
Magnitude::min()
Inherited From SObject
SObject::asA()
SObject::asString()
SObject::copy()
SObject::copySameFrom()
SObject::copyTwoLevel()
SObject::deepCopy()
SObject::isEqual()
SObject::isEqualTo()
SObject::isNotEqualTo()
SObject::isNotReferenceTo()
SObject::isReferenceTo()
SObject::newFrom()
SObject::postCopy()
SObject::printableString()
SObject::shallowCopy()
SObject::_deepCopyArray()
Documentation generated on Wed, 19 Sep 2007 10:25:17 -0400 by phpDocumentor 1.3.0RC3