mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-29 16:30:19 +02:00
Add the ability to represent non-real complex numbers whose imaginary part is an _inexact_ zero (0.0 or -0.0), per R6RS. Previously, such numbers were immediately changed into inexact reals. * libguile/numbers.c: Remove from the list of `General assumptions' in numbers.c that objects satisfying SCM_COMPLEXP() have a non-zero complex component. This is no longer true. Also add a warning about another unrelated assumption that is not entirely correct (that floor(r) == r implies that mpz_set_d will DTRT; it won't if r is infinite). (icmplx2str): Always print the imaginary part, even if it is zero. Also handle a negative zero imaginary part more gracefully. It now prints 0.0-0.0i, where previously it would print 0.0+-0.0i. (mem2ureal): Replace scm_from_double (0.0) with flo0. (scm_c_make_rectangular): Always create non-real complex numbers. Previously it would create inexact reals if the specified imaginary part was zero. (scm_make_rectangular): If the imaginary part is an _exact_ 0, return the real part unchanged (possibly exact), otherwise return a non-real complex number (possibly with an inexact zero imaginary part). Previously, it would return an inexact real number whenever the imaginary part was any kind of zero. (scm_make_polar): If the magnitude is an exact 0, return an exact 0. If the angle is an exact 0, return the magnitude unchanged (possibly exact). Otherwise return a non-real complex number (possibly with an inexact zero imaginary part). Previously, it would return a real number whenever the imaginary part was any kind of zero. (scm_imag_part): Return an exact 0 if applied to a real number. Previously it would return an inexact zero if applied to an inexact real number. (scm_inexact_to_exact): Accept complex numbers with inexact zero imaginary part. In that case, simply use the real part and ignore the imaginary part. Essentially we coerce the inexact zero imaginary part to an exact 0. * test-suite/tests/numbers.test: Add many test cases, and modify existing tests as needed to reflect these changes. Also add a new internal predicate: `almost-real-nan?' which tests for a non-real complex number with zero imaginary part whose real part is a NaN. * doc/ref/api-data.texi (Complex Numbers): Update description of complex numbers to reflect these changes: non-real complex numbers in Guile need not have non-zero imaginary part. Also, each part of a complex number may be any inexact real, not just rationals as was previously stated. Explicitly mention that each part may be an infinity, a NaN, or a signed zero. (Complex Number Operations): Change the formal parameter names of `make-polar' from `x' and `y' to `mag' and `ang'. * NEWS: Add news entries. |
||
---|---|---|
.. | ||
.gitignore | ||
api-binding.texi | ||
api-compound.texi | ||
api-control.texi | ||
api-coverage.texi | ||
api-data.texi | ||
api-debug.texi | ||
api-deprecated.texi | ||
api-evaluation.texi | ||
api-foreign.texi | ||
api-i18n.texi | ||
api-init.texi | ||
api-io.texi | ||
api-lalr.texi | ||
api-languages.texi | ||
api-macros.texi | ||
api-memory.texi | ||
api-modules.texi | ||
api-options.texi | ||
api-overview.texi | ||
api-procedures.texi | ||
api-regex.texi | ||
api-scheduling.texi | ||
api-scm.texi | ||
api-smobs.texi | ||
api-snarf.texi | ||
api-undocumented.texi | ||
api-utility.texi | ||
api.txt | ||
autoconf.texi | ||
ChangeLog-2008 | ||
ChangeLog-goops-2008 | ||
ChangeLog-guile-doc-ref | ||
compiler.texi | ||
data-rep.texi | ||
effective-version.texi.in | ||
expect.texi | ||
fdl.texi | ||
gds.dia | ||
gds.eps | ||
gds.pdf | ||
gds.txt | ||
goops-tutorial.texi | ||
goops.texi | ||
guile.texi | ||
hierarchy.eps | ||
hierarchy.pdf | ||
hierarchy.png | ||
hierarchy.txt | ||
history.texi | ||
indices.texi | ||
intro.texi | ||
libguile-concepts.texi | ||
libguile-extensions.texi | ||
libguile-linking.texi | ||
libguile-program.texi | ||
libguile-smobs.texi | ||
libguile-snarf.texi | ||
make-texinfo.scm | ||
Makefile.am | ||
match.texi | ||
misc-modules.texi | ||
mod-getopt-long.texi | ||
mop.text | ||
new-docstrings.texi | ||
posix.texi | ||
preface.texi | ||
r6rs.texi | ||
repl-modules.texi | ||
scheme-ideas.texi | ||
scheme-indices.texi | ||
scheme-intro.texi | ||
scheme-reading.texi | ||
scheme-scripts.texi | ||
scheme-using.texi | ||
scheme.dia | ||
scheme.eps | ||
scheme.pdf | ||
scheme.txt | ||
script-getopt.texi | ||
scsh.texi | ||
slib.texi | ||
srfi-modules.texi | ||
standard-library.am | ||
standard-library.scm | ||
sxml-match.texi | ||
tools.texi | ||
tour.texi | ||
vm.texi | ||
web.texi |