The number classes currently supported in CLDT are Integer, Fraction, and Float, which provide abstractions for the mathematical concepts of integers, rational numbers (fractions), and real numbers (floating point). The CLDT number classes do not deal explicitly with precision or other properties of numbers that depend on implementation. Another class, Decimal, deals explicitly with precision. Decimal class is a subclass of Number and is defined in DecimalMath.
For example, a platform might support two or more implementations of a number class that have identical behavior, except that they represent numbers with different precisions or different signs. These classes would not be distinguished in CLDT. In contrast, most other Smalltalk systems support several different integer classes, such as SmallInteger, LargeInteger, LargePositiveInteger, and LargeNegativeInteger. Each class is constrained regarding the size or sign of the integers that it can represent. However, each of these classes supports the same Integer protocol defined in CLDT.
Developers do not usually need to be aware of the distinctions between the different representations of number classes, but at the same time the distinctions cannot be completely ignored. Some applications depend on knowledge of the platform-specific implementation of a number class and so are unlikely to be portable. An example is a numerical application in which the results depend on whether floating point numbers use single or double precision.
All number classes support the following basic protocol:
*, +, -, /, //, \\, abs, negated, quo:, rem:
@, asFloat, asFraction, asInteger, degreesToRadians, radiansToDegrees
negative, positive, strictlyPositive
to:, to:by:, to:by:do:, to:do:
lessGeneralThan:, moreGeneralThan:
arcCos, arcSin, arcTan, cos, exp, floorLog:, ln, log:, raisedTo:, raisedToInteger:, reciprocal, sign, sin, sqrt, squared, tan
ceiling, floor, rounded, roundTo:, truncated, truncateTo: