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

Numbers

A number in MzScheme is one of the following:

MzScheme extends the number syntax of R5RS in two ways:

The special inexact numbers +inf.0, -inf.0, and +nan.0 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?. The +nan.0 value is not an integer and is not = to itself, but +nan.0 is eqv? to itself.[footnote] Similarly, (= 0.0 -0.0) is #t, but (eqv? 0.0 -0.0) is #f.

All multi-argument arithmetic procedures operate pairwise on arguments from left to right.

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:mismatch 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]     [index]
Next: Characters Up: Basic Data Extensions Previous: Booleans

PLT