aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2012-09-10 19:28:27 -0700
committerPaul Eggert2012-09-10 19:28:27 -0700
commitc990426a9883c1bd1782e6b117184b654eecda67 (patch)
tree43083f890e5286637ee754482af0f92d6d2236d0
parent6fda35f2b3e3ce3c7dcc05f230f60c51c4c42e60 (diff)
downloademacs-c990426a9883c1bd1782e6b117184b654eecda67.tar.gz
emacs-c990426a9883c1bd1782e6b117184b654eecda67.zip
Simplify, document, and port floating-point.
The porting part of this patch fixes bugs on non-IEEE platforms with frexp, ldexp, logb. * admin/CPP-DEFINES (HAVE_CBRT, HAVE_LOGB, logb): Remove. * configure.ac (logb, cbrt): Do not check for these functions, as they are not being used. * doc/lispref/numbers.texi (Float Basics, Arithmetic Operations, Math Functions): Document that / and mod (with floating point arguments), along with asin, acos, log, log10, expt and sqrt, return special values instead of signaling exceptions. (Float Basics): Document that logb operates on the absolute value of its argument. (Math Functions): Document that (log ARG BASE) also returns NaN if BASE is negative. Document that (expt X Y) returns NaN if X is a finite negative number and Y a finite non-integer. * etc/NEWS: Document NaNs versus signaling-error change. * src/data.c, src/lisp.h (Qdomain_error, Qsingularity_error, Qunderflow_error): Now static. * src/floatfns.c: Simplify discussion of functions that Emacs doesn't support, by removing commented-out code and briefly listing the C89 functions excluded. The commented-out stuff was confusing maintenance, e.g., we thought we needed cbrt but it was commented out. (logb): Remove decl; no longer needed. (isfinite): New macro, if not already supplied. (isnan): Don't replace any existing macro. (Ffrexp, Fldexp): Define even if !HAVE_COPYSIGN, as frexp and ldexp are present on all C89 platforms. (Ffrexp): Do not special-case zero, as frexp does the right thing for that case. (Flogb): Do not use logb, as it doesn't have the desired meaning on hosts that use non-base-2 floating point. Instead, stick with frexp, which is C89 anyway. Do not pass an infinity or a NaN to frexp, to avoid getting an unspecified result.
-rw-r--r--ChangeLog6
-rw-r--r--admin/CPP-DEFINES4
-rw-r--r--admin/ChangeLog5
-rw-r--r--configure.ac6
-rw-r--r--doc/lispref/ChangeLog13
-rw-r--r--doc/lispref/numbers.texi35
-rw-r--r--etc/ChangeLog5
-rw-r--r--etc/NEWS8
-rw-r--r--src/ChangeLog21
-rw-r--r--src/data.c4
-rw-r--r--src/floatfns.c231
-rw-r--r--src/lisp.h3
12 files changed, 105 insertions, 236 deletions
diff --git a/ChangeLog b/ChangeLog
index 7d1c19a535e..3d6d5020b0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
12012-09-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify, document, and port floating-point (Bug#12381).
4 * configure.ac (logb, cbrt): Do not check for these functions,
5 as they are not being used.
6
12012-09-10 Paul Eggert <eggert@cs.ucla.edu> 72012-09-10 Paul Eggert <eggert@cs.ucla.edu>
2 8
3 Improve robustness of 'make bootstrap' (Bug#12376). 9 Improve robustness of 'make bootstrap' (Bug#12376).
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index b40ba78e20d..cf6ffee2c63 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -120,7 +120,6 @@ HAVE_ATTRIBUTE_ALIGNED
120HAVE_BDFFONT 120HAVE_BDFFONT
121HAVE_BOXES 121HAVE_BOXES
122HAVE_C99_STRTOLD 122HAVE_C99_STRTOLD
123HAVE_CBRT
124HAVE_CFMAKERAW 123HAVE_CFMAKERAW
125HAVE_CFSETSPEED 124HAVE_CFSETSPEED
126HAVE_CLOCK_GETTIME 125HAVE_CLOCK_GETTIME
@@ -251,7 +250,6 @@ HAVE_LIBXMU
251HAVE_LINUX_VERSION_H 250HAVE_LINUX_VERSION_H
252HAVE_LOCALTIME_R 251HAVE_LOCALTIME_R
253HAVE_LOCAL_SOCKETS 252HAVE_LOCAL_SOCKETS
254HAVE_LOGB
255HAVE_LONG_FILE_NAMES 253HAVE_LONG_FILE_NAMES
256HAVE_LONG_LONG_INT 254HAVE_LONG_LONG_INT
257HAVE_LRAND48 255HAVE_LRAND48
@@ -574,7 +572,6 @@ getpid
574isatty 572isatty
575kill 573kill
576link 574link
577logb
578lseek 575lseek
579mkdir 576mkdir
580mktemp 577mktemp
@@ -616,7 +613,6 @@ fopen
616getpid 613getpid
617index 614index
618isatty 615isatty
619logb
620lseek 616lseek
621mkdir 617mkdir
622mktemp 618mktemp
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 2c61f437981..b70067d7465 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,8 @@
12012-09-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify, document, and port floating-point (Bug#12381).
4 * CPP-DEFINES (HAVE_CBRT, HAVE_LOGB, logb): Remove.
5
12012-09-09 Paul Eggert <eggert@cs.ucla.edu> 62012-09-09 Paul Eggert <eggert@cs.ucla.edu>
2 7
3 Assume C89 or later for math functions (Bug#12381). 8 Assume C89 or later for math functions (Bug#12381).
diff --git a/configure.ac b/configure.ac
index 97e967d8043..9491c1da8d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2689,8 +2689,8 @@ if test $emacs_cv_netdb_declares_h_errno = yes; then
2689 AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.]) 2689 AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.])
2690fi 2690fi
2691 2691
2692# fmod, logb, and frexp are found in -lm on most systems. 2692# sqrt and other floating-point functions such as fmod and frexp
2693# On HPUX 9.01, -lm does not contain logb, so check for sqrt. 2693# are found in -lm on most systems.
2694AC_CHECK_LIB(m, sqrt) 2694AC_CHECK_LIB(m, sqrt)
2695 2695
2696# Check for mail-locking functions in a "mail" library. Probably this should 2696# Check for mail-locking functions in a "mail" library. Probably this should
@@ -2770,7 +2770,7 @@ AC_SUBST(BLESSMAIL_TARGET)
2770 2770
2771AC_CHECK_FUNCS(gethostname \ 2771AC_CHECK_FUNCS(gethostname \
2772closedir getrusage get_current_dir_name \ 2772closedir getrusage get_current_dir_name \
2773lrand48 logb cbrt setsid \ 2773lrand48 setsid \
2774fpathconf select euidaccess getpagesize setlocale \ 2774fpathconf select euidaccess getpagesize setlocale \
2775utimes getrlimit setrlimit setpgid getcwd shutdown getaddrinfo \ 2775utimes getrlimit setrlimit setpgid getcwd shutdown getaddrinfo \
2776__fpending strsignal setitimer \ 2776__fpending strsignal setitimer \
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index ceb199dae88..ce99c81a912 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,16 @@
12012-09-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify, document, and port floating-point (Bug#12381).
4 * numbers.texi (Float Basics, Arithmetic Operations, Math Functions):
5 Document that / and mod (with floating point arguments), along
6 with asin, acos, log, log10, expt and sqrt, return special values
7 instead of signaling exceptions.
8 (Float Basics): Document that logb operates on the absolute value
9 of its argument.
10 (Math Functions): Document that (log ARG BASE) also returns NaN if
11 BASE is negative. Document that (expt X Y) returns NaN if X is a
12 finite negative number and Y a finite non-integer.
13
12012-09-09 Chong Yidong <cyd@gnu.org> 142012-09-09 Chong Yidong <cyd@gnu.org>
2 15
3 * lists.texi (Sets And Lists): Explain that the return value for 16 * lists.texi (Sets And Lists): Explain that the return value for
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index 17f3ee099bd..7c9672a38c0 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -196,6 +196,14 @@ numerical functions return such values in cases where there is no
196correct answer. For example, @code{(/ 0.0 0.0)} returns a NaN. (NaN 196correct answer. For example, @code{(/ 0.0 0.0)} returns a NaN. (NaN
197values can also carry a sign, but for practical purposes there's no 197values can also carry a sign, but for practical purposes there's no
198significant difference between different NaN values in Emacs Lisp.) 198significant difference between different NaN values in Emacs Lisp.)
199
200When a function is documented to return a NaN, it returns an
201implementation-defined value when Emacs is running on one of the
202now-rare platforms that do not use @acronym{IEEE} floating point. For
203example, @code{(log -1.0)} typically returns a NaN, but on
204non-@acronym{IEEE} platforms it returns an implementation-defined
205value.
206
199Here are the read syntaxes for these special floating point values: 207Here are the read syntaxes for these special floating point values:
200 208
201@table @asis 209@table @asis
@@ -241,7 +249,7 @@ numbers.
241 249
242@defun logb number 250@defun logb number
243This function returns the binary exponent of @var{number}. More 251This function returns the binary exponent of @var{number}. More
244precisely, the value is the logarithm of @var{number} base 2, rounded 252precisely, the value is the logarithm of |@var{number}| base 2, rounded
245down to an integer. 253down to an integer.
246 254
247@example 255@example
@@ -694,7 +702,8 @@ arguments. It also permits floating point arguments; it rounds the
694quotient downward (towards minus infinity) to an integer, and uses that 702quotient downward (towards minus infinity) to an integer, and uses that
695quotient to compute the remainder. 703quotient to compute the remainder.
696 704
697An @code{arith-error} results if @var{divisor} is 0. 705If @var{divisor} is zero, @code{mod} signals an @code{arith-error}
706error if both arguments are integers, and returns a NaN otherwise.
698 707
699@example 708@example
700@group 709@group
@@ -1096,8 +1105,8 @@ pi/2
1096@tex 1105@tex
1097@math{\pi/2} 1106@math{\pi/2}
1098@end tex 1107@end tex
1099(inclusive) whose sine is @var{arg}; if, however, @var{arg} is out of 1108(inclusive) whose sine is @var{arg}. If @var{arg} is out of range
1100range (outside [@minus{}1, 1]), it signals a @code{domain-error} error. 1109(outside [@minus{}1, 1]), @code{asin} returns a NaN.
1101@end defun 1110@end defun
1102 1111
1103@defun acos arg 1112@defun acos arg
@@ -1108,8 +1117,8 @@ pi
1108@tex 1117@tex
1109@math{\pi} 1118@math{\pi}
1110@end tex 1119@end tex
1111(inclusive) whose cosine is @var{arg}; if, however, @var{arg} is out 1120(inclusive) whose cosine is @var{arg}. If @var{arg} is out of range
1112of range (outside [@minus{}1, 1]), it signals a @code{domain-error} error. 1121(outside [@minus{}1, 1]), @code{acos} returns a NaN.
1113@end defun 1122@end defun
1114 1123
1115@defun atan y &optional x 1124@defun atan y &optional x
@@ -1141,8 +1150,8 @@ This is the exponential function; it returns @math{e} to the power
1141@defun log arg &optional base 1150@defun log arg &optional base
1142This function returns the logarithm of @var{arg}, with base 1151This function returns the logarithm of @var{arg}, with base
1143@var{base}. If you don't specify @var{base}, the natural base 1152@var{base}. If you don't specify @var{base}, the natural base
1144@math{e} is used. If @var{arg} is negative, it signals a 1153@math{e} is used. If @var{arg} or @var{base} is negative, @code{log}
1145@code{domain-error} error. 1154returns a NaN.
1146@end defun 1155@end defun
1147 1156
1148@ignore 1157@ignore
@@ -1160,21 +1169,21 @@ lose accuracy.
1160@end ignore 1169@end ignore
1161 1170
1162@defun log10 arg 1171@defun log10 arg
1163This function returns the logarithm of @var{arg}, with base 10. If 1172This function returns the logarithm of @var{arg}, with base 10:
1164@var{arg} is negative, it signals a @code{domain-error} error. 1173@code{(log10 @var{x})} @equiv{} @code{(log @var{x} 10)}.
1165@code{(log10 @var{x})} @equiv{} @code{(log @var{x} 10)}, at least
1166approximately.
1167@end defun 1174@end defun
1168 1175
1169@defun expt x y 1176@defun expt x y
1170This function returns @var{x} raised to power @var{y}. If both 1177This function returns @var{x} raised to power @var{y}. If both
1171arguments are integers and @var{y} is positive, the result is an 1178arguments are integers and @var{y} is positive, the result is an
1172integer; in this case, overflow causes truncation, so watch out. 1179integer; in this case, overflow causes truncation, so watch out.
1180If @var{x} is a finite negative number and @var{y} is a finite
1181non-integer, @code{expt} returns a NaN.
1173@end defun 1182@end defun
1174 1183
1175@defun sqrt arg 1184@defun sqrt arg
1176This returns the square root of @var{arg}. If @var{arg} is negative, 1185This returns the square root of @var{arg}. If @var{arg} is negative,
1177it signals a @code{domain-error} error. 1186@code{sqrt} returns a NaN.
1178@end defun 1187@end defun
1179 1188
1180In addition, Emacs defines the following common mathematical 1189In addition, Emacs defines the following common mathematical
diff --git a/etc/ChangeLog b/etc/ChangeLog
index aa788275256..11e7e5ca108 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,8 @@
12012-09-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify, document, and port floating-point (Bug#12381).
4 * NEWS: Document NaNs versus signaling-error change.
5
12012-09-04 Paul Eggert <eggert@cs.ucla.edu> 62012-09-04 Paul Eggert <eggert@cs.ucla.edu>
2 7
3 Give more-useful info on a fatal error (Bug#12328). 8 Give more-useful info on a fatal error (Bug#12328).
diff --git a/etc/NEWS b/etc/NEWS
index ef68e2e561e..af4bcf11dbb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -729,6 +729,14 @@ table, but with a different prefix.
729must be in the range 1000..9999. It now works with any year supported 729must be in the range 1000..9999. It now works with any year supported
730by the underlying C implementation. 730by the underlying C implementation.
731 731
732** Floating point
733
734*** When floating point functions such as `log' are given invalid
735arguments, e.g., (log -1.0), they now uniformly return special values
736such as NaNs instead of signaling errors. Previously, these functions
737returned NaNs on some platforms but signaled errors on others. The affected
738functions are acos, asin, tan, exp, expt, log, log10, sqrt, and mod.
739
732** New function file-name-base. 740** New function file-name-base.
733 741
734** New function `tty-top-frame' returns the topmost frame of a text terminal. 742** New function `tty-top-frame' returns the topmost frame of a text terminal.
diff --git a/src/ChangeLog b/src/ChangeLog
index 4eda17da3a7..0e5bbfd2524 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,26 @@
12012-09-11 Paul Eggert <eggert@cs.ucla.edu> 12012-09-11 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Simplify, document, and port floating-point (Bug#12381).
4 The porting part of this patch fixes bugs on non-IEEE platforms
5 with frexp, ldexp, logb.
6 * data.c, lisp.h (Qdomain_error, Qsingularity_error, Qunderflow_error):
7 Now static.
8 * floatfns.c: Simplify discussion of functions that Emacs doesn't
9 support, by removing commented-out code and briefly listing the
10 C89 functions excluded. The commented-out stuff was confusing
11 maintenance, e.g., we thought we needed cbrt but it was commented out.
12 (logb): Remove decl; no longer needed.
13 (isfinite): New macro, if not already supplied.
14 (isnan): Don't replace any existing macro.
15 (Ffrexp, Fldexp): Define even if !HAVE_COPYSIGN, as frexp and ldexp
16 are present on all C89 platforms.
17 (Ffrexp): Do not special-case zero, as frexp does the right thing
18 for that case.
19 (Flogb): Do not use logb, as it doesn't have the desired meaning
20 on hosts that use non-base-2 floating point. Instead, stick with
21 frexp, which is C89 anyway. Do not pass an infinity or a NaN to
22 frexp, to avoid getting an unspecified result.
23
3 * xdisp.c (Qinhibit_debug_on_message): Now static. 24 * xdisp.c (Qinhibit_debug_on_message): Now static.
4 25
52012-09-10 Jan Djärv <jan.h.d@swipnet.se> 262012-09-10 Jan Djärv <jan.h.d@swipnet.se>
diff --git a/src/data.c b/src/data.c
index a4cca0a3ee5..4678ac1208c 100644
--- a/src/data.c
+++ b/src/data.c
@@ -71,8 +71,8 @@ Lisp_Object Qchar_table_p, Qvector_or_char_table_p;
71Lisp_Object Qcdr; 71Lisp_Object Qcdr;
72static Lisp_Object Qad_advice_info, Qad_activate_internal; 72static Lisp_Object Qad_advice_info, Qad_activate_internal;
73 73
74Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; 74static Lisp_Object Qdomain_error, Qsingularity_error, Qunderflow_error;
75Lisp_Object Qoverflow_error, Qunderflow_error; 75Lisp_Object Qrange_error, Qoverflow_error;
76 76
77Lisp_Object Qfloatp; 77Lisp_Object Qfloatp;
78Lisp_Object Qnumberp, Qnumber_or_marker_p; 78Lisp_Object Qnumberp, Qnumber_or_marker_p;
diff --git a/src/floatfns.c b/src/floatfns.c
index 8a9a9fd0886..66d7ca4af2c 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -22,9 +22,10 @@ You should have received a copy of the GNU General Public License
22along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 22along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 23
24 24
25/* C89 requires only these math.h functions: 25/* C89 requires only the following math.h functions, and Emacs omits
26 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, 26 the starred functions since we haven't found a use for them:
27 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh. 27 acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod,
28 frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh.
28 */ 29 */
29 30
30#include <config.h> 31#include <config.h>
@@ -42,10 +43,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42 43
43#include <math.h> 44#include <math.h>
44 45
45/* This declaration is omitted on some systems, like Ultrix. */ 46#ifndef isfinite
46#if !defined (HPUX) && defined (HAVE_LOGB) && !defined (logb) 47# define isfinite(x) ((x) - (x) == 0)
47extern double logb (double); 48#endif
48#endif /* not HPUX and HAVE_LOGB and no logb macro */ 49#ifndef isnan
50# define isnan(x) ((x) != (x))
51#endif
49 52
50/* Extract a Lisp number as a `double', or signal an error. */ 53/* Extract a Lisp number as a `double', or signal an error. */
51 54
@@ -126,9 +129,6 @@ DEFUN ("tan", Ftan, Stan, 1, 1, 0,
126 return make_float (d); 129 return make_float (d);
127} 130}
128 131
129#undef isnan
130#define isnan(x) ((x) != (x))
131
132DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, 132DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
133 doc: /* Return non nil iff argument X is a NaN. */) 133 doc: /* Return non nil iff argument X is a NaN. */)
134 (Lisp_Object x) 134 (Lisp_Object x)
@@ -153,6 +153,7 @@ Cause an error if X1 or X2 is not a float. */)
153 153
154 return make_float (copysign (f1, f2)); 154 return make_float (copysign (f1, f2));
155} 155}
156#endif
156 157
157DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0, 158DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0,
158 doc: /* Get significand and exponent of a floating point number. 159 doc: /* Get significand and exponent of a floating point number.
@@ -167,15 +168,9 @@ If X is zero, both parts (SGNFCAND and EXP) are zero. */)
167 (Lisp_Object x) 168 (Lisp_Object x)
168{ 169{
169 double f = XFLOATINT (x); 170 double f = XFLOATINT (x);
170 171 int exponent;
171 if (f == 0.0) 172 double sgnfcand = frexp (f, &exponent);
172 return Fcons (make_float (0.0), make_number (0)); 173 return Fcons (make_float (sgnfcand), make_number (exponent));
173 else
174 {
175 int exponent;
176 double sgnfcand = frexp (f, &exponent);
177 return Fcons (make_float (sgnfcand), make_number (exponent));
178 }
179} 174}
180 175
181DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0, 176DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0,
@@ -187,118 +182,6 @@ Returns the floating point value resulting from multiplying SGNFCAND
187 CHECK_NUMBER (exponent); 182 CHECK_NUMBER (exponent);
188 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent))); 183 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent)));
189} 184}
190#endif
191
192#if 0 /* Leave these out unless we find there's a reason for them. */
193
194DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0,
195 doc: /* Return the bessel function j0 of ARG. */)
196 (Lisp_Object arg)
197{
198 double d = extract_float (arg);
199 d = j0 (d);
200 return make_float (d);
201}
202
203DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0,
204 doc: /* Return the bessel function j1 of ARG. */)
205 (Lisp_Object arg)
206{
207 double d = extract_float (arg);
208 d = j1 (d);
209 return make_float (d);
210}
211
212DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0,
213 doc: /* Return the order N bessel function output jn of ARG.
214The first arg (the order) is truncated to an integer. */)
215 (Lisp_Object n, Lisp_Object arg)
216{
217 int i1 = extract_float (n);
218 double f2 = extract_float (arg);
219
220 f2 = jn (i1, f2);
221 return make_float (f2);
222}
223
224DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0,
225 doc: /* Return the bessel function y0 of ARG. */)
226 (Lisp_Object arg)
227{
228 double d = extract_float (arg);
229 d = y0 (d);
230 return make_float (d);
231}
232
233DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0,
234 doc: /* Return the bessel function y1 of ARG. */)
235 (Lisp_Object arg)
236{
237 double d = extract_float (arg);
238 d = y1 (d);
239 return make_float (d);
240}
241
242DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0,
243 doc: /* Return the order N bessel function output yn of ARG.
244The first arg (the order) is truncated to an integer. */)
245 (Lisp_Object n, Lisp_Object arg)
246{
247 int i1 = extract_float (n);
248 double f2 = extract_float (arg);
249
250 f2 = yn (i1, f2);
251 return make_float (f2);
252}
253
254#endif
255
256#if 0 /* Leave these out unless we see they are worth having. */
257
258DEFUN ("erf", Ferf, Serf, 1, 1, 0,
259 doc: /* Return the mathematical error function of ARG. */)
260 (Lisp_Object arg)
261{
262 double d = extract_float (arg);
263 d = erf (d);
264 return make_float (d);
265}
266
267DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
268 doc: /* Return the complementary error function of ARG. */)
269 (Lisp_Object arg)
270{
271 double d = extract_float (arg);
272 d = erfc (d);
273 return make_float (d);
274}
275
276DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
277 doc: /* Return the log gamma of ARG. */)
278 (Lisp_Object arg)
279{
280 double d = extract_float (arg);
281 d = lgamma (d);
282 return make_float (d);
283}
284
285DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
286 doc: /* Return the cube root of ARG. */)
287 (Lisp_Object arg)
288{
289 double d = extract_float (arg);
290#ifdef HAVE_CBRT
291 d = cbrt (d);
292#else
293 if (d >= 0.0)
294 d = pow (d, 1.0/3.0);
295 else
296 d = -pow (-d, 1.0/3.0);
297#endif
298 return make_float (d);
299}
300
301#endif
302 185
303DEFUN ("exp", Fexp, Sexp, 1, 1, 0, 186DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
304 doc: /* Return the exponential base e of ARG. */) 187 doc: /* Return the exponential base e of ARG. */)
@@ -383,63 +266,6 @@ DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
383 return make_float (d); 266 return make_float (d);
384} 267}
385 268
386#if 0 /* Not clearly worth adding. */
387
388DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
389 doc: /* Return the inverse hyperbolic cosine of ARG. */)
390 (Lisp_Object arg)
391{
392 double d = extract_float (arg);
393 d = acosh (d);
394 return make_float (d);
395}
396
397DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
398 doc: /* Return the inverse hyperbolic sine of ARG. */)
399 (Lisp_Object arg)
400{
401 double d = extract_float (arg);
402 d = asinh (d);
403 return make_float (d);
404}
405
406DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
407 doc: /* Return the inverse hyperbolic tangent of ARG. */)
408 (Lisp_Object arg)
409{
410 double d = extract_float (arg);
411 d = atanh (d);
412 return make_float (d);
413}
414
415DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
416 doc: /* Return the hyperbolic cosine of ARG. */)
417 (Lisp_Object arg)
418{
419 double d = extract_float (arg);
420 d = cosh (d);
421 return make_float (d);
422}
423
424DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
425 doc: /* Return the hyperbolic sine of ARG. */)
426 (Lisp_Object arg)
427{
428 double d = extract_float (arg);
429 d = sinh (d);
430 return make_float (d);
431}
432
433DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
434 doc: /* Return the hyperbolic tangent of ARG. */)
435 (Lisp_Object arg)
436{
437 double d = extract_float (arg);
438 d = tanh (d);
439 return make_float (d);
440}
441#endif
442
443DEFUN ("abs", Fabs, Sabs, 1, 1, 0, 269DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
444 doc: /* Return the absolute value of ARG. */) 270 doc: /* Return the absolute value of ARG. */)
445 (register Lisp_Object arg) 271 (register Lisp_Object arg)
@@ -477,16 +303,15 @@ This is the same as the exponent of a float. */)
477 303
478 if (f == 0.0) 304 if (f == 0.0)
479 value = MOST_NEGATIVE_FIXNUM; 305 value = MOST_NEGATIVE_FIXNUM;
480 else 306 else if (isfinite (f))
481 { 307 {
482#ifdef HAVE_LOGB
483 value = logb (f);
484#else
485 int ivalue; 308 int ivalue;
486 frexp (f, &ivalue); 309 frexp (f, &ivalue);
487 value = ivalue - 1; 310 value = ivalue - 1;
488#endif
489 } 311 }
312 else
313 value = MOST_POSITIVE_FIXNUM;
314
490 XSETINT (val, value); 315 XSETINT (val, value);
491 return val; 316 return val;
492} 317}
@@ -719,27 +544,9 @@ syms_of_floatfns (void)
719 defsubr (&Sisnan); 544 defsubr (&Sisnan);
720#ifdef HAVE_COPYSIGN 545#ifdef HAVE_COPYSIGN
721 defsubr (&Scopysign); 546 defsubr (&Scopysign);
547#endif
722 defsubr (&Sfrexp); 548 defsubr (&Sfrexp);
723 defsubr (&Sldexp); 549 defsubr (&Sldexp);
724#endif
725#if 0
726 defsubr (&Sacosh);
727 defsubr (&Sasinh);
728 defsubr (&Satanh);
729 defsubr (&Scosh);
730 defsubr (&Ssinh);
731 defsubr (&Stanh);
732 defsubr (&Sbessel_y0);
733 defsubr (&Sbessel_y1);
734 defsubr (&Sbessel_yn);
735 defsubr (&Sbessel_j0);
736 defsubr (&Sbessel_j1);
737 defsubr (&Sbessel_jn);
738 defsubr (&Serf);
739 defsubr (&Serfc);
740 defsubr (&Slog_gamma);
741 defsubr (&Scube_root);
742#endif
743 defsubr (&Sfceiling); 550 defsubr (&Sfceiling);
744 defsubr (&Sffloor); 551 defsubr (&Sffloor);
745 defsubr (&Sfround); 552 defsubr (&Sfround);
diff --git a/src/lisp.h b/src/lisp.h
index 240e8c08a87..ae9b3422534 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2559,8 +2559,7 @@ extern Lisp_Object Qchar_table_p, Qvector_or_char_table_p;
2559 2559
2560extern Lisp_Object Qcdr; 2560extern Lisp_Object Qcdr;
2561 2561
2562extern Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; 2562extern Lisp_Object Qrange_error, Qoverflow_error;
2563extern Lisp_Object Qoverflow_error, Qunderflow_error;
2564 2563
2565extern Lisp_Object Qfloatp; 2564extern Lisp_Object Qfloatp;
2566extern Lisp_Object Qnumberp, Qnumber_or_marker_p; 2565extern Lisp_Object Qnumberp, Qnumber_or_marker_p;