diff options
| author | Po Lu | 2023-05-04 22:08:44 +0800 |
|---|---|---|
| committer | Po Lu | 2023-05-04 22:09:14 +0800 |
| commit | 2f3a514b6db5e0d0453c56a4f201088ea99d5139 (patch) | |
| tree | 8c950c38605cd5a562b853f870fde33bbeba595b | |
| parent | 94e984e6700c805c3aaac6f8d9c56381a8d0673a (diff) | |
| download | emacs-2f3a514b6db5e0d0453c56a4f201088ea99d5139.tar.gz emacs-2f3a514b6db5e0d0453c56a4f201088ea99d5139.zip | |
Clarify documentation wrt floating point division by zero and NaN
* doc/lispref/numbers.texi (Float Basics)
(Arithmetic Operations): Document what happens on a VAX.
Tested on NetBSD 9.3.
| -rw-r--r-- | doc/lispref/numbers.texi | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 9bfb771fc07..3e45aa90fda 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi | |||
| @@ -219,17 +219,25 @@ creates huge integers. | |||
| 219 | 219 | ||
| 220 | @cindex @acronym{IEEE} floating point | 220 | @cindex @acronym{IEEE} floating point |
| 221 | Floating-point numbers are useful for representing numbers that are | 221 | Floating-point numbers are useful for representing numbers that are |
| 222 | not integral. The range of floating-point numbers is | 222 | not integral. The range of floating-point numbers is the same as the |
| 223 | the same as the range of the C data type @code{double} on the machine | 223 | range of the C data type @code{double} on the machine you are using. |
| 224 | you are using. On all computers supported by Emacs, this is | 224 | On almost all computers supported by Emacs, this is @acronym{IEEE} |
| 225 | @acronym{IEEE} binary64 floating point format, which is standardized by | 225 | binary64 floating point format, which is standardized by |
| 226 | @url{https://standards.ieee.org/standard/754-2019.html,,IEEE Std 754-2019} | 226 | @url{https://standards.ieee.org/standard/754-2019.html,,IEEE Std |
| 227 | and is discussed further in David Goldberg's paper | 227 | 754-2019} and is discussed further in David Goldberg's paper |
| 228 | ``@url{https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html, | 228 | ``@url{https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html, |
| 229 | What Every Computer Scientist Should Know About Floating-Point Arithmetic}''. | 229 | What Every Computer Scientist Should Know About Floating-Point |
| 230 | On modern platforms, floating-point operations follow the IEEE-754 | 230 | Arithmetic}''. On modern platforms, floating-point operations follow |
| 231 | standard closely; however, results are not always rounded correctly on | 231 | the IEEE-754 standard closely; however, results are not always rounded |
| 232 | some obsolescent platforms, notably 32-bit x86. | 232 | correctly on some systems, notably 32-bit x86. |
| 233 | |||
| 234 | On some old computer systems, Emacs may not use IEEE floating-point. | ||
| 235 | We know of one such system on which Emacs runs correctly, but does not | ||
| 236 | follow IEEE-754: the VAX running NetBSD using GCC 10.4.0, where the | ||
| 237 | VAX @samp{D_Floating} format is used instead. IBM System/370-derived | ||
| 238 | mainframes and their XL/C compiler are also capable of utilizing a | ||
| 239 | hexadecimal floating point format, but Emacs has not yet been built in | ||
| 240 | such a configuration. | ||
| 233 | 241 | ||
| 234 | The read syntax for floating-point numbers requires either a decimal | 242 | The read syntax for floating-point numbers requires either a decimal |
| 235 | point, an exponent, or both. Optional signs (@samp{+} or @samp{-}) | 243 | point, an exponent, or both. Optional signs (@samp{+} or @samp{-}) |
| @@ -262,6 +270,10 @@ two NaNs as equal when their | |||
| 262 | signs and significands agree. Significands of NaNs are | 270 | signs and significands agree. Significands of NaNs are |
| 263 | machine-dependent, as are the digits in their string representation. | 271 | machine-dependent, as are the digits in their string representation. |
| 264 | 272 | ||
| 273 | NaNs are not available on systems which do not use IEEE | ||
| 274 | floating-point arithmetic; if the read syntax for a NaN is used on a | ||
| 275 | VAX, for example, the reader signals an error. | ||
| 276 | |||
| 265 | When NaNs and signed zeros are involved, non-numeric functions like | 277 | When NaNs and signed zeros are involved, non-numeric functions like |
| 266 | @code{eql}, @code{equal}, @code{sxhash-eql}, @code{sxhash-equal} and | 278 | @code{eql}, @code{equal}, @code{sxhash-eql}, @code{sxhash-equal} and |
| 267 | @code{gethash} determine whether values are indistinguishable, not | 279 | @code{gethash} determine whether values are indistinguishable, not |
| @@ -742,9 +754,10 @@ by rounding the quotient towards zero after each division. | |||
| 742 | 754 | ||
| 743 | @cindex @code{arith-error} in division | 755 | @cindex @code{arith-error} in division |
| 744 | If you divide an integer by the integer 0, Emacs signals an | 756 | If you divide an integer by the integer 0, Emacs signals an |
| 745 | @code{arith-error} error (@pxref{Errors}). Floating-point division of | 757 | @code{arith-error} error (@pxref{Errors}). On systems using IEEE-754 |
| 746 | a nonzero number by zero yields either positive or negative infinity | 758 | floating-point, floating-point division of a nonzero number by zero |
| 747 | (@pxref{Float Basics}). | 759 | yields either positive or negative infinity (@pxref{Float Basics}); |
| 760 | otherwise, an @code{arith-error} is signaled as usual. | ||
| 748 | @end defun | 761 | @end defun |
| 749 | 762 | ||
| 750 | @defun % dividend divisor | 763 | @defun % dividend divisor |