7.6.2.22 rnrs arithmetic flonums

The (rnrs arithmetic flonums (6)) library provides procedures for performing arithmetic operations on inexact representations of real numbers, which R6RS refers to as flonums.

Unless otherwise specified, all of the procedures below take flonums as arguments, and will raise an &assertion condition if passed a non-flonum argument.

Scheme Procedure: flonum? obj

Returns #t if obj is a flonum, #f otherwise.

Scheme Procedure: real->flonum x

Returns the flonum that is numerically closest to the real number x.

Scheme Procedure: fl=? fl1 fl2 fl3 ...
Scheme Procedure: fl<? fl1 fl2 fl3 ...
Scheme Procedure: fl<=? fl1 fl2 fl3 ...
Scheme Procedure: fl>? fl1 fl2 fl3 ...
Scheme Procedure: fl>=? fl1 fl2 fl3 ...

These procedures return #t if their flonum arguments are (respectively): equal, monotonically increasing, monotonically decreasing, monotonically nondecreasing, or monotonically nonincreasing; #f otherwise.

Scheme Procedure: flinteger? fl
Scheme Procedure: flzero? fl
Scheme Procedure: flpositive? fl
Scheme Procedure: flnegative? fl
Scheme Procedure: flodd? fl
Scheme Procedure: fleven? fl

These numerical predicates return #t if fl is, respectively, an integer, zero, greater than zero, less than zero, odd, even, #f otherwise. In the case of flodd? and fleven?, fl must be an integer-valued flonum.

Scheme Procedure: flfinite? fl
Scheme Procedure: flinfinite? fl
Scheme Procedure: flnan? fl

These numerical predicates return #t if fl is, respectively, not infinite, infinite, or a NaN value.

Scheme Procedure: flmax fl1 fl2 ...
Scheme Procedure: flmin fl1 fl2 ...

These procedures return the maximum or minimum of their arguments.

Scheme Procedure: fl+ fl1 ...
Scheme Procedure: fl* fl ...

These procedures return the sum or product of their arguments.

Scheme Procedure: fl- fl1 fl2 ...
Scheme Procedure: fl- fl
Scheme Procedure: fl/ fl1 fl2 ...
Scheme Procedure: fl/ fl

These procedures return, respectively, the difference or quotient of their arguments when called with two arguments; when called with a single argument, they return the additive or multiplicative inverse of fl.

Scheme Procedure: flabs fl

Returns the absolute value of fl.

Scheme Procedure: fldiv-and-mod fl1 fl2
Scheme Procedure: fldiv fl1 fl2
Scheme Procedure: fldmod fl1 fl2
Scheme Procedure: fldiv0-and-mod0 fl1 fl2
Scheme Procedure: fldiv0 fl1 fl2
Scheme Procedure: flmod0 fl1 fl2

These procedures implement number-theoretic division on flonums; See (rnrs base), for a description for their semantics.

Scheme Procedure: flnumerator fl
Scheme Procedure: fldenominator fl

These procedures return the numerator or denominator of fl as a flonum.

Scheme Procedure: flfloor fl1
Scheme Procedure: flceiling fl
Scheme Procedure: fltruncate fl
Scheme Procedure: flround fl

These procedures are identical to the floor, ceiling, truncate, and round procedures provided by Guile’s core library. See Arithmetic Functions, for documentation.

Scheme Procedure: flexp fl
Scheme Procedure: fllog fl
Scheme Procedure: fllog fl1 fl2
Scheme Procedure: flsin fl
Scheme Procedure: flcos fl
Scheme Procedure: fltan fl
Scheme Procedure: flasin fl
Scheme Procedure: flacos fl
Scheme Procedure: flatan fl
Scheme Procedure: flatan fl1 fl2

These procedures, which compute the usual transcendental functions, are the flonum variants of the procedures provided by the R6RS base library (see (rnrs base)).

Scheme Procedure: flsqrt fl

Returns the square root of fl. If fl is -0.0, -0.0 is returned; for other negative values, a NaN value is returned.

Scheme Procedure: flexpt fl1 fl2

Returns the value of fl1 raised to the power of fl2.

The following condition types are provided to allow Scheme implementations that do not support infinities or NaN values to indicate that a computation resulted in such a value. Guile supports both of these, so these conditions will never be raised by Guile’s standard libraries implementation.

Condition Type: &no-infinities
Scheme Procedure: make-no-infinities-violation obj
Scheme Procedure: no-infinities-violation?

A condition type indicating that a computation resulted in an infinite value on a Scheme implementation incapable of representing infinities.

Condition Type: &no-nans
Scheme Procedure: make-no-nans-violation obj
Scheme Procedure: no-nans-violation? obj

A condition type indicating that a computation resulted in a NaN value on a Scheme implementation incapable of representing NaNs.

Scheme Procedure: fixnum->flonum fx

Returns the flonum that is numerically closest to the fixnum fx.