Numerical tower
From Wikipedia, the free encyclopedia
In computing, a numerical tower is the set of number types (data types that represent numbers) in a given programming language.
Each type in the tower conceptually "sits on" a more fundamental type, so an integer is a rational number and a number, but the inverse is not necessarily true, i.e. not every number is an integer; this asymmetry implies that a language can allow implicit coercions of numerical types - without creating semantic problems - in only one direction: coercing an integer to a rational loses no information and does not affect the results of a function, but to coerce most reals to an integer could well result in a problem (for example, the real 1/3 does not equal any integer).
Typically a language will support a modified version of this numerical tower; Kawa Scheme, for example, extends this basic numerical tower with a Quantity type that is even more generic than Number, while Smalltalk has Magnitude as superclass of Number. Another popular variant is having both exact and inexact versions of the tower or parts of it. Some languages and language implementations do not support a full numerical tower or support it only in a limited way.