diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-03-17 18:19:03 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-03-17 18:19:03 -0700 |
commit | 09b73f0820fd38194b46aa71e1652c594a25586c (patch) | |
tree | 6de632fe9e072e0645864ca8b2c83303ea17884b /doc/lispref/numbers.texi | |
parent | 07f44fdbfe0060781773f04867cfe1e1a1411f83 (diff) | |
download | emacs-09b73f0820fd38194b46aa71e1652c594a25586c.tar.gz |
Style fixes for floating-point doc.
* commands.texi, customize.texi, display.texi, elisp.texi, files.texi:
* frames.texi, hash.texi, internals.texi, keymaps.texi, lists.texi:
* minibuf.texi, nonascii.texi, numbers.texi, objects.texi, os.texi:
* processes.texi, streams.texi, strings.texi, text.texi:
* variables.texi, windows.texi:
Hyphenate "floating-point" iff it precedes a noun.
Reword to avoid nouns and hyphenation when that's easy.
Prefer "integer" to "integer number" and "is floating point"
to "is a floating point number".
Prefer "@minus{}" to "-" when it's a minus.
Diffstat (limited to 'doc/lispref/numbers.texi')
-rw-r--r-- | doc/lispref/numbers.texi | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 2e8fefed1c5..d202877e8ad 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi @@ -10,7 +10,7 @@ GNU Emacs supports two numeric data types: @dfn{integers} and @dfn{floating point numbers}. Integers are whole numbers such as -@minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point +@minus{}3, 0, 7, 13, and 511. Their values are exact. Floating-point numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or 2.71828. They can also be expressed in exponential notation: 1.5e2 equals 150; in this example, @samp{e2} stands for ten to the second @@ -24,7 +24,7 @@ exact; they have a fixed, limited amount of precision. * Comparison of Numbers:: Equality and inequality predicates. * Numeric Conversions:: Converting float to integer and vice versa. * Arithmetic Operations:: How to add, subtract, multiply and divide. -* Rounding Operations:: Explicitly rounding floating point numbers. +* Rounding Operations:: Explicitly rounding floating-point numbers. * Bitwise Operations:: Logical and, or, not, shifting. * Math Functions:: Trig, exponential and logarithmic functions. * Random Numbers:: Obtaining random integers, predictable or not. @@ -36,7 +36,7 @@ exact; they have a fixed, limited amount of precision. The range of values for an integer depends on the machine. The minimum range is @minus{}536870912 to 536870911 (30 bits; i.e., @ifnottex --2**29 +@minus{}2**29 @end ifnottex @tex @math{-2^{29}} @@ -122,7 +122,7 @@ complement} notation.) 1111...111011 (30 bits total) @end example - In this implementation, the largest 30-bit binary integer value is + In this implementation, the largest 30-bit binary integer is 536,870,911 in decimal. In binary, it looks like this: @example @@ -145,15 +145,15 @@ arguments to such functions may be either numbers or markers, we often give these arguments the name @var{number-or-marker}. When the argument value is a marker, its position value is used and its buffer is ignored. -@cindex largest Lisp integer number -@cindex maximum Lisp integer number +@cindex largest Lisp integer +@cindex maximum Lisp integer @defvar most-positive-fixnum The value of this variable is the largest integer that Emacs Lisp can handle. @end defvar -@cindex smallest Lisp integer number -@cindex minimum Lisp integer number +@cindex smallest Lisp integer +@cindex minimum Lisp integer @defvar most-negative-fixnum The value of this variable is the smallest integer that Emacs Lisp can handle. It is negative. @@ -164,33 +164,33 @@ integer between zero and the value of @code{max-char}, inclusive, is considered to be valid as a character. @xref{String Basics}. @node Float Basics -@section Floating Point Basics +@section Floating-Point Basics @cindex @acronym{IEEE} floating point - Floating point numbers are useful for representing numbers that are -not integral. The precise range of floating point numbers is + Floating-point numbers are useful for representing numbers that are +not integral. The precise range of floating-point numbers is machine-specific; it is the same as the range of the C data type @code{double} on the machine you are using. Emacs uses the -@acronym{IEEE} floating point standard, which is supported by all +@acronym{IEEE} floating-point standard, which is supported by all modern computers. - The read syntax for floating point numbers requires either a decimal + The read syntax for floating-point numbers requires either a decimal point (with at least one digit following), an exponent, or both. For example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2}, @samp{1.5e3}, and -@samp{.15e4} are five ways of writing a floating point number whose +@samp{.15e4} are five ways of writing a floating-point number whose value is 1500. They are all equivalent. You can also use a minus -sign to write negative floating point numbers, as in @samp{-1.0}. +sign to write negative floating-point numbers, as in @samp{-1.0}. - Emacs Lisp treats @code{-0.0} as equal to ordinary zero (with + Emacs Lisp treats @code{-0.0} as numerically equal to ordinary zero (with respect to @code{equal} and @code{=}), even though the two are -distinguishable in the @acronym{IEEE} floating point standard. +distinguishable in the @acronym{IEEE} floating-point standard. @cindex positive infinity @cindex negative infinity @cindex infinity @cindex NaN - The @acronym{IEEE} floating point standard supports positive -infinity and negative infinity as floating point values. It also + The @acronym{IEEE} floating-point standard supports positive +infinity and negative infinity as floating-point values. It also provides for a class of values called NaN or ``not-a-number''; numerical functions return such values in cases where there is no correct answer. For example, @code{(/ 0.0 0.0)} returns a NaN@. (NaN @@ -204,7 +204,7 @@ example, @code{(log -1.0)} typically returns a NaN, but on non-@acronym{IEEE} platforms it returns an implementation-defined value. -Here are the read syntaxes for these special floating point values: +Here are the read syntaxes for these special floating-point values: @table @asis @item positive infinity @@ -272,8 +272,8 @@ its argument. See also @code{integer-or-marker-p} and @code{number-or-marker-p}, in @ref{Predicates on Markers}. @defun floatp object -This predicate tests whether its argument is a floating point -number and returns @code{t} if so, @code{nil} otherwise. +This predicate tests whether its argument is floating point +and returns @code{t} if so, @code{nil} otherwise. @end defun @defun integerp object @@ -310,13 +310,13 @@ if so, @code{nil} otherwise. The argument must be a number. @cindex comparing numbers To test numbers for numerical equality, you should normally use -@code{=}, not @code{eq}. There can be many distinct floating point -number objects with the same numeric value. If you use @code{eq} to +@code{=}, not @code{eq}. There can be many distinct floating-point +objects with the same numeric value. If you use @code{eq} to compare them, then you test whether two values are the same @emph{object}. By contrast, @code{=} compares only the numeric values of the objects. - In Emacs Lisp, each integer value is a unique Lisp object. + In Emacs Lisp, each integer is a unique Lisp object. Therefore, @code{eq} is equivalent to @code{=} where integers are concerned. It is sometimes convenient to use @code{eq} for comparing an unknown value with an integer, because @code{eq} does not report an @@ -328,12 +328,12 @@ use @code{=} if you can, even for comparing integers. Sometimes it is useful to compare numbers with @code{equal}, which treats two numbers as equal if they have the same data type (both integers, or both floating point) and the same value. By contrast, -@code{=} can treat an integer and a floating point number as equal. +@code{=} can treat an integer and a floating-point number as equal. @xref{Equality Predicates}. - There is another wrinkle: because floating point arithmetic is not -exact, it is often a bad idea to check for equality of two floating -point values. Usually it is better to test for approximate equality. + There is another wrinkle: because floating-point arithmetic is not +exact, it is often a bad idea to check for equality of floating-point +values. Usually it is better to test for approximate equality. Here's a function to do this: @example @@ -351,7 +351,7 @@ Here's a function to do this: @code{=} because Common Lisp implements multi-word integers, and two distinct integer objects can have the same numeric value. Emacs Lisp can have just one integer object for any given value because it has a -limited range of integer values. +limited range of integers. @end quotation @defun = number-or-marker &rest number-or-markers @@ -397,7 +397,7 @@ otherwise. @defun max number-or-marker &rest numbers-or-markers This function returns the largest of its arguments. -If any of the arguments is floating-point, the value is returned +If any of the arguments is floating point, the value is returned as floating point, even if it was given as an integer. @example @@ -412,7 +412,7 @@ as floating point, even if it was given as an integer. @defun min number-or-marker &rest numbers-or-markers This function returns the smallest of its arguments. -If any of the arguments is floating-point, the value is returned +If any of the arguments is floating point, the value is returned as floating point, even if it was given as an integer. @example @@ -435,20 +435,20 @@ To convert an integer to floating point, use the function @code{float}. @defun float number This returns @var{number} converted to floating point. -If @var{number} is already a floating point number, @code{float} returns +If @var{number} is already floating point, @code{float} returns it unchanged. @end defun - There are four functions to convert floating point numbers to + There are four functions to convert floating-point numbers to integers; they differ in how they round. All accept an argument @var{number} and an optional argument @var{divisor}. Both arguments -may be integers or floating point numbers. @var{divisor} may also be +may be integers or floating-point numbers. @var{divisor} may also be @code{nil}. If @var{divisor} is @code{nil} or omitted, these functions convert @var{number} to an integer, or return it unchanged if it already is an integer. If @var{divisor} is non-@code{nil}, they divide @var{number} by @var{divisor} and convert the result to an integer. If @var{divisor} is zero (whether integer or -floating-point), Emacs signals an @code{arith-error} error. +floating point), Emacs signals an @code{arith-error} error. @defun truncate number &optional divisor This returns @var{number}, converted to an integer by rounding towards @@ -529,8 +529,8 @@ depending on your machine. (addition, subtraction, multiplication, and division), as well as remainder and modulus functions, and functions to add or subtract 1. Except for @code{%}, each of these functions accepts both integer and -floating point arguments, and returns a floating point number if any -argument is a floating point number. +floating-point arguments, and returns a floating-point number if any +argument is floating point. It is important to note that in Emacs Lisp, arithmetic functions do not check for overflow. Thus @code{(1+ 536870911)} may evaluate to @@ -659,9 +659,9 @@ does not happen in practice.) @cindex @code{arith-error} in division If you divide an integer by the integer 0, Emacs signals an -@code{arith-error} error (@pxref{Errors}). If you divide a floating -point number by 0, or divide by the floating point number 0.0, the -result is either positive or negative infinity (@pxref{Float Basics}). +@code{arith-error} error (@pxref{Errors}). Floating-point division of +a nonzero number by zero yields either positive or negative infinity +(@pxref{Float Basics}). @end defun @defun % dividend divisor @@ -701,7 +701,7 @@ in other words, the remainder after division of @var{dividend} by @var{divisor}, but with the same sign as @var{divisor}. The arguments must be numbers or markers. -Unlike @code{%}, @code{mod} permits floating point arguments; it +Unlike @code{%}, @code{mod} permits floating-point arguments; it rounds the quotient downward (towards minus infinity) to an integer, and uses that quotient to compute the remainder. @@ -751,30 +751,30 @@ Conversions}. @cindex rounding without conversion The functions @code{ffloor}, @code{fceiling}, @code{fround}, and -@code{ftruncate} take a floating point argument and return a floating -point result whose value is a nearby integer. @code{ffloor} returns the +@code{ftruncate} take a floating-point argument and return a floating-point +result whose value is a nearby integer. @code{ffloor} returns the nearest integer below; @code{fceiling}, the nearest integer above; @code{ftruncate}, the nearest integer in the direction towards zero; @code{fround}, the nearest integer. @defun ffloor float This function rounds @var{float} to the next lower integral value, and -returns that value as a floating point number. +returns that value as a floating-point number. @end defun @defun fceiling float This function rounds @var{float} to the next higher integral value, and -returns that value as a floating point number. +returns that value as a floating-point number. @end defun @defun ftruncate float This function rounds @var{float} towards zero to an integral value, and -returns that value as a floating point number. +returns that value as a floating-point number. @end defun @defun fround float This function rounds @var{float} to the nearest integral value, -and returns that value as a floating point number. +and returns that value as a floating-point number. @end defun @node Bitwise Operations @@ -1083,7 +1083,7 @@ bit is one in the result if, and only if, the @var{n}th bit is zero in @cindex mathematical functions @cindex floating-point functions - These mathematical functions allow integers as well as floating point + These mathematical functions allow integers as well as floating-point numbers as arguments. @defun sin arg |