R5RS requires that, with few exceptions, a calculation involving inexact
numbers always produces an inexact result. To meet this requirement,
Guile distinguishes between an exact integer value such as ‘5’ and
the corresponding inexact integer value which, to the limited precision
available, has no fractional part, and is printed as ‘5.0’. Guile
will only convert the latter value to the former when forced to do so by
an invocation of the inexact->exact procedure.
The only exception to the above requirement is when the values of the
inexact numbers do not affect the result. For example (expt n 0)
is ‘1’ for any value of n, therefore (expt 5.0 0) is
permitted to return an exact ‘1’.
Return
#tif the number z is exact,#fotherwise.(exact? 2) ⇒ #t (exact? 0.5) ⇒ #f (exact? (/ 2)) ⇒ #t
Return a
1if the number z is exact, and0otherwise. This is equivalent toscm_is_true (scm_exact_p (z)).An alternate approch to testing the exactness of a number is to use
scm_is_signed_integerorscm_is_unsigned_integer.
Return
#tif the number z is inexact,#felse.
Return a
1if the number z is inexact, and0otherwise. This is equivalent toscm_is_true (scm_inexact_p (z)).
Return an exact number that is numerically closest to z, when there is one. For inexact rationals, Guile returns the exact rational that is numerically equal to the inexact rational. Inexact complex numbers with a non-zero imaginary part can not be made exact.
(inexact->exact 0.5) ⇒ 1/2The following happens because 12/10 is not exactly representable as a
double(on most platforms). However, when reading a decimal number that has been marked exact with the “#e” prefix, Guile is able to represent it correctly.(inexact->exact 1.2) ⇒ 5404319552844595/4503599627370496 #e1.2 ⇒ 6/5