Numerical tower
Encyclopedia
In Scheme and some other Lisp dialects, a numerical tower is the set of data types that represent number
Number
A number is a mathematical object used to count and measure. In mathematics, the definition of number has been extended over the years to include such numbers as zero, negative numbers, rational numbers, irrational numbers, and complex numbers....

s in a given programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

.

Each type in the tower conceptually "sits on" a more fundamental type, so an integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

 is a rational number
Rational number
In mathematics, a rational number is any number that can be expressed as the quotient or fraction a/b of two integers, with the denominator b not equal to zero. Since b may be equal to 1, every 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
Type conversion
In computer science, type conversion, typecasting, and coercion are different ways of, implicitly or explicitly, changing an entity of one data type into another. This is done to take advantage of certain features of type hierarchies or type representations...

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

Scheme programming language, and also other Lisp dialects, defines all its arithmetic within this model. Some given implementations may extend or adapt the tower. Kawa, for example, extends it with a Quantity type that is even more generic than Number. Smalltalk
Smalltalk
Smalltalk is an object-oriented, dynamically typed, reflective programming language. Smalltalk was created as the language to underpin the "new world" of computing exemplified by "human–computer symbiosis." It was designed and created in part for educational use, more so for constructionist...

 is another programming language that follows this model, but it has a Magnitude as superclass of Number. Another popular variant is having both exact and inexact versions of the tower or parts of it. Most languages and language implementations do not support a Scheme-like numerical tower. Some languages support it only in a limited way.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK