On this page:
4.4.1 Types
number?
complex?
real?
rational?
integer?
natural?
exact?
inexact?
4.4.2 Generic Arithmethic
+
-
*
/
add1
sub1
zero?
4.4.2.1 Comparison
number=?
number<?
number>?
number≤?
number≥?
4.4.2.2 Contracts
number=/  c
number</  c
number>/  c
number≤/  c
number≥/  c
real-in
integer-in
8.12

4.4 Numbers🔗

Elle inherits the Scheme Numerical Tower. More precisely, Elle inherits Racket’s implementation of the Numerical Tower.

4.4.1 Types🔗

procedure

(number? v)  boolean?

  v : any/c
Returns #true, if v is a number; #false, otherwise. This procedure is an alias for complex?, since all numbers are complex numbers.

procedure

(complex? v)  boolean?

  v : any/c
Returns #true, if v is a complex number; #false, otherwise.

procedure

(real? v)  boolean?

  v : any/c
Returns #true, if v is a complex number whose imaginary part is zero.

procedure

(rational? v)  boolean?

  v : any/c
Returns #true, if v is a rational number; #false, otherwise.

procedure

(integer? v)  boolean?

  v : any/c
Returns #true, if v is an integer; #false, otherwise.

procedure

(natural? v)  boolean?

  v : any/c
Returns #true, if v is a natural number; #false, otherwise.

procedure

(exact? z)  boolean?

  z : number?
Returns #true, if z is an exact number; #false, otherwise.

procedure

(inexact? z)  boolean?

  z : number?
Returns #true, if z is an inexact number; #false, otherwise.

4.4.2 Generic Arithmethic🔗

procedure

(+ z ...)  number?

  z : number?
Returns the sum of the zs. In the special case of one z, this procedure is the identity. In the special case of zero zs, returns an exact zero.

procedure

(- z ...+)  number?

  z : number?
Returns the differents of the zs. In the special case of one z, returns the additive inverse of the z.

procedure

(* z ...)  number?

  z : number?
Returns the product of the zs. In the special case of one z, this procedure is the identity. In the special case of zero zs, returns an exact one.

procedure

(/ z ...+)  number?

  z : number?
Returns the quotient of the zs. In the special case of one z, returns the multiplicative inverse (reciprocal) of z.

procedure

(add1 z)  number?

  z : number?
Equivalent to (+ z 1).

procedure

(sub1 z)  number?

  z : number?
Equivalent to (- z 1).

procedure

(zero? z)  boolean?

  z : number?
Returns #true, if z is exact or inexact zero; #false, otherwise.

4.4.2.1 Comparison🔗

procedure

(number=? z ...+)  boolean?

  z : number?
Returns #true, if all zs are numerically equivalent; #false, otherwise. Inexact numbers are coerced to exactness before comparison.

procedure

(number<? x ...+)  boolean?

  x : real?
Returns #true, if all xs are ordered by numerically increasing value; #false, otherwise.

procedure

(number>? x ...+)  boolean?

  x : real?
Returns #true, if all xs are ordered by numerically decreasing value; #false, otherwise.

procedure

(number≤? x ...+)  boolean?

  x : real?
Returns #true, if all xs are ordered by numerically nondecreasing value; #false, otherwise.

procedure

(number≥? x ...+)  boolean?

  x : real?
Returns #true, if all xs are ordered by numerically nonincreasing value; #false, otherwise.

4.4.2.2 Contracts🔗

procedure

(number=/c x)  flat-contract?

  x : real?
Returns a flat contract that requires a real number that is numerically equivalent to x.

procedure

(number</c x)  flat-contract?

  x : real?
Returns a flat contract that requires a real number that numerically less than x.

procedure

(number>/c x)  flat-contract?

  x : real?
Returns a flat contract that requires a real number that is numerically greater than x.

procedure

(number≤/c x)  flat-contract?

  x : real?
Returns a flat contract that requires a real nummber that is either numerically equivalent or less than x.

procedure

(number≥/c x)  flat-contract?

  x : real?
Returns a flat contract that requires a real number that is either numerically equivalent or greater than x.

procedure

(real-in x1 x2)  flat-contract?

  x1 : real?
  x2 : real?
Returns a flat contract that requires a real number that is between x1 and x2, inclusive.

procedure

(integer-in i1 i2)  flat-contract?

  i1 : integer?
  i2 : integer?
Returns a flat contract that requires an integer that is between i1 and i2, inclusive.