[previous] [up] [next]     [contents] [index]
Next: Characters Up: Basic Data Extensions Previous: Booleans

Numbers

A number in MzScheme is one of the following:

The following are inexact numerical constants: +inf.0 (infinity), -inf.0 (negative infinity), +nan.0 (not a number), and -nan.0 (same as +nan.0). They have no exact form. Dividing by an inexact zero returns +inf.0 or -inf.0, depending on the sign of the dividend. The infinities are integers, and they answer #t for both even? and odd?; +nan.0 is not an integer and is not = to itself, but +nan.0 is eqv? to itself.[footnote] No numerical operator distinguishes the inexact numbers 0.0 and -0.0, so (= 0.0 (/ -1 +inf.0)) is #t.

All multi-argument arithmetic procedures operate pairwise on arguments from right to left. When an arithmetic operation is applied to a combination of exact and inexact values, the exact values are first converted to inexact values. All numbers are either inexact or exact in both real and imaginary parts (i.e., an inexact ``real'' number is not even exactly real because its imaginary part is 0.0).

The string->number procedure works on all number representations and exact integer radix values in the range 2 to 16 (inclusive). The number->string procedure accepts all number types and the radix values 2, 8, 10, and 16; however, if an inexact number is provided with a radix other than 10, the exn:application:math:radix exception is raised.

The add1 and sub1 procedures work on any number:

The following procedures work on exact integers in their (semi-infinite) two's complement representation:

The random procedure generates pseudo-random integers:


[previous] [up] [next]     [contents] [index]
Next: Characters Up: Basic Data Extensions Previous: Booleans

PLT