4.3.1 Number Types (original) (raw)
4.3.1 Number Types🔗ℹ
Returns #t if v is a number, #f otherwise.
Examples:
> (number? 1) #t > (number? 2+3i) #t > (number? "hello") #f > (number? +nan.0) #t
Returns #t if v is a real number, #f otherwise.
Examples:
> (real? 1) #t > (real? +inf.0) #t > (real? 2+3i) #f > (real? 2.0+0.0i) #f > (real? "hello") #f
Examples:
> (rational? 1) #t > (rational? +inf.0) #f > (rational? "hello") #f
Returns #t if v is a number that is an integer, #f otherwise.
Examples:
> (integer? 1) #t > (integer? 2.3) #f > (integer? 4.0) #t > (integer? +inf.0) #f > (integer? 2+3i) #f > (integer? "hello") #f
Returns (and (integer? v) (exact? v)).
Examples:
> (exact-integer? 1) #t > (exact-integer? 4.0) #f
Returns (and (exact-integer? v) (not (negative? v))).
Examples:
Returns (and (exact-integer? v) (positive? v)).
Examples:
Returns (and (real? v) (inexact? v)).
Return #t if v is a fixnum, #fotherwise.
Note: the result of this function is platform-dependent, so using it in syntax transformers can lead to platform-dependent bytecode files. See also fixnum-for-every-system?.
Return #t if v is a flonum, #fotherwise.
Identical to flonum?.
Return #t ifv is a single-flonum (i.e., a single-precision floating-point number), #f otherwise.
Returns #t if single-flonums are supported on the current platform, #f otherwise.
Currently, single-flonum-available? produces #t when(system-type 'vm) produces 'racket, andsingle-flonum-available? produces #f otherwise.
If the result is #f, then single-flonum? also produces #f for all arguments.
Added in version 7.3.0.5 of package base.
Returns (= 0 z).
Examples:
> (zero? 0) #t > (zero? -0.0) #t
Returns (> x 0).
Examples:
> (positive? 10) #t > (positive? -10) #f > (positive? 0.0) #f
Returns (< x 0).
Examples:
> (negative? 10) #f > (negative? -10) #t > (negative? -0.0) #f
Examples:
> (even? 10.0) #t > (even? 11) #f > (even? +inf.0) even?: contract violation expected: integer? given: +inf.0
Examples:
> (odd? 10.0) #f > (odd? 11) #t > (odd? +inf.0) odd?: contract violation expected: integer? given: +inf.0
Returns #t if z is an exact number, #f otherwise.
Examples:
> (exact? 1) #t > (exact? 1.0) #f
Returns #t if z is an inexact number, #f otherwise.
Examples:
> (inexact? 1) #f > (inexact? 1.0) #t
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 theexn:fail:contract exception is raised.
Examples:
> (inexact->exact 1) 1 > (inexact->exact 1.0) 1
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
Coerces xto a single-precision floating-point number. If x is already a single-precision floating-point number, it is returned.
Coerces xto a double-precision floating-point number. If x is already a double-precision floating-point number, it is returned.