4.2.1 Number Types
Returns #t if v
is a number, #f otherwise.
Examples:
Examples:
Examples:
Examples:
> (integer? 1) #t
> (integer? 2.3) #f
> (integer? 4.0) #t
> (integer? +inf.0) #f
> (integer? 2+3i) #f
> (integer? "hello") #f
procedure
(exact-integer? v) → boolean?
v : any/c
Examples:
> (exact-integer? 1) #t
> (exact-integer? 4.0) #f
procedure
v : any/c
Examples:
> (exact-nonnegative-integer? 0) #t
> (exact-nonnegative-integer? -1) #f
procedure
v : any/c
Examples:
> (exact-positive-integer? 1) #t
> (exact-positive-integer? 0) #f
procedure
(inexact-real? v) → boolean?
v : any/c
Note: the result of this function is platform-dependent, so using it in syntax transformers can lead to platform-dependent bytecode files.
procedure
(double-flonum? v) → boolean?
v : any/c
Identical to flonum?.
procedure
(single-flonum? v) → boolean?
v : any/c
Return #t if v is a single-precision floating-point
number, #f otherwise.
Examples:
Examples:
Examples:
Examples:
> (even? 10.0) #t
> (even? 11) #f
> (even? +inf.0) even?: contract violation
expected: integer
given: +inf.0
Examples:
Returns #t if z
is an exact number, #f otherwise.
Examples:
Returns #t if z
is an inexact number, #f otherwise.
Examples:
procedure
(inexact->exact z) → exact?
z : number?
Coerces z to an
exact number. If z is already exact, it is returned. If z
is +inf.0, -inf.0, +nan.0,
+inf.f, -inf.f, or +nan.f, then the
exn:fail:contract exception is raised.
Examples:
> (inexact->exact 1) 1
> (inexact->exact 1.0) 1
procedure
(exact->inexact z) → inexact?
z : number?
Coerces z to an
inexact number. If z is already inexact, it is returned.
Examples:
> (exact->inexact 1) 1.0
> (exact->inexact 1.0) 1.0
procedure
x : real?
Coerces x
to a single-precision floating-point number. If x is already
a single-precision floating-point number, it is returned.
procedure
(real->double-flonum x) → flonum?
x : real?
Coerces x
to a double-precision floating-point number. If x is already
a double-precision floating-point number, it is returned.