5.3.2
11 Flonums
This library is unstable;
compatibility will not be maintained.
See Unstable: May Change Without Warning for more information.
(require unstable/flonum) |
procedure
(flonum->bit-field x) → (integer-in 0 (- (expt 2 64) 1))
x : flonum?
Returns the bits comprising x as an integer.
A convenient shortcut for composing integer-bytes->integer with real->floating-point-bytes.
Examples: | ||||||||||||||
|
procedure
(bit-field->flonum i) → flonum?
i : (integer-in 0 (- (expt 2 64) 1))
The inverse of flonum->bit-field.
procedure
(flonum->ordinal x)
→ (integer-in (- (- (expt 2 63) 1)) (- (expt 2 63) 1)) x : flonum?
Returns the signed ordinal index of x in a total order over flonums.
When inputs are not +nan.0, this function is monotone and symmetric;
i.e. if (fl<= x y) then (<= (flonum->ordinal x) (flonum->ordinal y)),
and (= (flonum->ordinal (- x)) (- (flonum->ordinal x))).
Examples: | ||||||||||||||
|
The following plot demonstrates how the density of floating-point numbers decreases with magnitude:
Example: | |||||
|
procedure
(ordinal->flonum i) → flonum?
i : (integer-in (- (- (expt 2 63) 1)) (- (expt 2 63) 1))
The inverse of flonum->ordinal.
procedure
(flonums-between x y) → exact-integer?
x : flonum? y : flonum?
Returns the number of flonums between x and y, excluding one endpoint.
Equivalent to (- (flonum->ordinal y) (flonum->ordinal x)).
Examples: | ||||||||
|
procedure
x : flonum? n : exact-integer?
Returns the flonum n flonums away from x, according to flonum->ordinal. If x is +nan.0, returns +nan.0.
Examples: | ||||||||||||||||
|
The rational flonums with maximum and minimum magnitude.