Numeric Values
Type Predicates
-
(
number?
val
) - Standard Scheme Procedure.
Determine if
val
is a number. -
(
integer?
val
) - Standard Scheme Procedure.
Determine whether
val
is an integer. -
(
rational?
val
) - Optional Scheme Procedure.
Determine whether
val
can be interpreted as a rational number. -
(
real?
val
) - Standard Scheme Procedure.
Determine whether
val
is a real number. -
(
complex?
val
) - Optional Scheme Procedure.
Determine whether
val
can be interpreted as a complex number.
Extrema
-
(
max
v1
v2
) - Standard Scheme Procedure.
Find the larger of
v1
andv2
. -
(
max
v1
v2
...vn
) - Standard Scheme Procedure.
Find the largest of
v1
throughvn
. -
(
min
v1
v2
) - Standard Scheme Procedure.
Find the smaller of
v1
andv2
. -
(
min
v1
v2
...vn
) - Standard Scheme Procedure.
Find the smallest of
v1
throughvn
.
Division-Related Procedures
-
(
quotient
dividend
divisor
) - Standard Scheme Procedure.
Find the quotient of
dividend
anddivisor
, both of which must be integers. The quotient is the whole part of the result of dividingdividend
bydivisor
. -
(
remainder
dividend
divisor
) - Standard Scheme Procedure.
Compute the remainder after doing whole-number division of
dividend
bydivisor
. -
(
modulo
value
modulus
) - Standard Scheme Procedure.
In a number line segmented into
modulus
-sized sections, gives the offset ofvalue
from the start of its section.
Converting Reals to Integers
-
(
floor
num
) - Standard Scheme Procedure.
Find the largest integer less than or equal to
num
. That is, round down. -
(
ceiling
num
) - Standard Scheme Procedure.
Find the smallest integer greater than or equal to
num
. That is, round up. -
(
truncate
num
) - Standard Scheme Procedure.
Remove any fractional part from
num
. That is, round toward zero. -
(
round
num
) - Standard Scheme Procedure.
Round
num
toward the nearest integer. If the decimal portion ofnum
is greater than 1/2, rounds up. If the decimal portion is less than 1/2, rounds down. If the decimal portion equals 1/2, may round in either direction. (In most implementations, numbers with fractional portions equal to 1/2 round toward the even number.)
Other Predicates
-
(
exact?
num
) - Standard Scheme Procedure.
Determine whether the numeric value
num
is represented exactly (that is, not approximated). -
(
inexact?
num
) - Standard Scheme Procedure.
Determine whether the numeric value
num
is represented inexactly (that is, approximated). -
(
even?
int
) - Standard Scheme Procedure.
Determine whether the integer value
int
is even (that is, has a remainder of 0 when divided by 2). -
(
odd?
int
) - Standard Scheme Procedure.
Determine whether the integer value
int
is odd (that is, has a remainder of 1 when divided by 2). -
(
zero?
num
) - Standard Scheme Procedure.
Determine whether the numeric value
num
is zero. -
(
positive?
num
) - Standard Scheme Procedure.
Determine whether the numeric value
num
is positive (greater than zero). -
(
negative?
num
) - Standard Scheme Procedure.
Determine whether the numeric value
num
is negative (less than zero).
Converting Representations
-
(
exact->inexact
num
) - Standard Scheme Procedure.
Create an inexact representation of
num
. -
(
inexact->exact
num
) - Standard Scheme Procedure.
Create an exact representation of
num
. (Of course, ifnum
was already approximated, the result, while exact, still approximates whatevernum
approximated.)
Other Procedures
-
(
abs
num
) - Standard Scheme Procedure.
Compute the absolute value of
num
. -
(
expt
base
power
) - Standard Scheme Procedure.
Compute
base
power
.