diff options
| author | Paul Eggert | 2019-01-06 16:23:41 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-01-06 16:25:40 -0800 |
| commit | 202bd7bff2710b98cde4ae4b6e1f6de9818591f8 (patch) | |
| tree | 5b58e9df997c158ccd6887a1c5ac81533040744f /doc | |
| parent | b0b483d714e87ee0a4572f9c541514a1ac1a8226 (diff) | |
| download | emacs-202bd7bff2710b98cde4ae4b6e1f6de9818591f8.tar.gz emacs-202bd7bff2710b98cde4ae4b6e1f6de9818591f8.zip | |
Fix logb on zero, infinite, NaN args
Change logb to return -infinity, +infinity, and NaN respectively.
Formerly logb returned an extreme fixnum to represent
infinity, but this is no longer the right thing to do now that
we have bignums and there is no extreme integer.
* doc/lispref/numbers.texi (Float Basics), etc/NEWS: Document.
* src/floatfns.c (Flogb): Implement this.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/numbers.texi | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index cffc634169f..fbdd83fa86e 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi | |||
| @@ -313,14 +313,18 @@ and returns the result. @var{x1} and @var{x2} must be floating point. | |||
| 313 | 313 | ||
| 314 | @defun logb x | 314 | @defun logb x |
| 315 | This function returns the binary exponent of @var{x}. More | 315 | This function returns the binary exponent of @var{x}. More |
| 316 | precisely, the value is the logarithm base 2 of @math{|x|}, rounded | 316 | precisely, if @var{x} is finite and nonzero, the value is the |
| 317 | down to an integer. | 317 | logarithm base 2 of @math{|x|}, rounded down to an integer. |
| 318 | If @var{x} is zero, infinite, or a NaN, the value is minus infinity, | ||
| 319 | plus infinity, or a NaN respectively. | ||
| 318 | 320 | ||
| 319 | @example | 321 | @example |
| 320 | (logb 10) | 322 | (logb 10) |
| 321 | @result{} 3 | 323 | @result{} 3 |
| 322 | (logb 10.0e20) | 324 | (logb 10.0e20) |
| 323 | @result{} 69 | 325 | @result{} 69 |
| 326 | (logb 0) | ||
| 327 | @result{} -1.0e+INF | ||
| 324 | @end example | 328 | @end example |
| 325 | @end defun | 329 | @end defun |
| 326 | 330 | ||