This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see NumericTower in WG2's repo for R7RS-large.

Numeric­Tower

cowan
2010-12-24 15:34:33
3history
source

The numeric tower

This is an analysis of the R5RS provision that the full numeric tower may be subsetted. Four boolean feature settings characterize different kinds of numeric towers: exactness-preserving, ratios, inexact, and complex, which refer to the closure of exact numbers under rational operations (except /), exact non-integer values, inexact rationals, and non-real numbers, respectively. A priori, any combination of these features might be implemented, except that ratios makes no sense without exactness-preserving. I also assume that complex makes no sense without either ratios or inexact: Gaussian integers by themselves seem to be of little use.

So here are ten possible numeric towers. I use + if a feature is present and - if it is absent, and give a general description of the resulting tower.

exactness-preserving

ratios

inexact

complex

Description

-

-

-

-

A "toy" tower with fixnums (bounded exact integers) only. Possibly appropriate where no numerical work will be done. SSCM, SigScheme provide this.

-

-

+

-

A Scheme where all numbers are real and all arithmetic happens in essentially constant time. Chicken provides this unless you import the numbers package. Sixx, Sizzle provide this. Most non-Lisp languages are like this, except that their fixnums wrap on overflow instead of switching to flonums, producing grossly incorrect results.

-

-

+

+

The complex-number equivalent of the preceding. Non-real numbers are typically inexact/inexact.

+

-

-

-

Unlimited-precision integers only. Possibly usable for crypto work. Fortunately, ratios are fairly cheap given bignums.

+

-

+

-

A good all-round compromise, providing exact integers and inexact real numbers. ISLisp requires this. Bigloo, Chibi, SCM, Scheme 9 provide this. Many people seem to like this tower.

+

-

+

+

The same as the preceding, but with inexact/inexact non-real numbers as well.

+

+

-

-

Exact rational numbers only. Dream provides this. Reasonable for some purposes, but will often run very slowly without inexact support, so unsuitable for scientific-type work.

+

-

+

+

The same as the preceding, but with exact general complex numbers. Even less suitable for scientific-type work, given that in practice non-real numbers are usually inexact/inexact.

+

+

+

-

Full numeric tower for real numbers only. Psyche provides this.

+

+

+

+

Full numeric tower. R6RS and CL require this. Racket, Gauche, MIT, Gambit, Chicken with the numbers package, Scheme48/scsh, Kawa, Chez, STklos provide this. Guile, SISC provide this, but don't have exact complex numbers. Many people seem to like this tower.