annotate src/floatfns.c @ 4726:f7a2f8a2f883

(vc-prefix-map): Bind C-x v ~ to vc-version-other-window.
author Paul Eggert <eggert@twinsun.com>
date Wed, 15 Sep 1993 23:19:13 +0000
parents 1fc792473491
children 136e32c763e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1 /* Primitive operations on floating point for GNU Emacs Lisp interpreter.
2961
e94a593c3952 Updated copyright years.
Jim Blandy <jimb@redhat.com>
parents: 2205
diff changeset
2 Copyright (C) 1988, 1993 Free Software Foundation, Inc.
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
3
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
5
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
9 any later version.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
10
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
15
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
19
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
20
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
21 /* ANSI C requires only these float functions:
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
22 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod,
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
23 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
24
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
25 Define HAVE_INVERSE_HYPERBOLIC if you have acosh, asinh, and atanh.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
26 Define HAVE_CBRT if you have cbrt.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
27 Define HAVE_RINT if you have rint.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
28 If you don't define these, then the appropriate routines will be simulated.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
29
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
30 Define HAVE_MATHERR if on a system supporting the SysV matherr callback.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
31 (This should happen automatically.)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
32
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
33 Define FLOAT_CHECK_ERRNO if the float library routines set errno.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
34 This has no effect if HAVE_MATHERR is defined.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
35
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
36 Define FLOAT_CATCH_SIGILL if the float library routines signal SIGILL.
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
37 (What systems actually do this? Please let us know.)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
38
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
39 Define FLOAT_CHECK_DOMAIN if the float library doesn't handle errors by
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
40 either setting errno, or signalling SIGFPE/SIGILL. Otherwise, domain and
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
41 range checking will happen before calling the float routines. This has
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
42 no effect if HAVE_MATHERR is defined (since matherr will be called when
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
43 a domain error occurs.)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
44 */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
45
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
46 #include <signal.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
47
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4594
diff changeset
48 #include <config.h>
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
49 #include "lisp.h"
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
50 #include "syssignal.h"
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
51
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
52 Lisp_Object Qarith_error;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
53
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
54 #ifdef LISP_FLOAT_TYPE
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
55
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
56 #include <math.h>
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
57
3094
4b3770f84aa7 (logb): Don't declare if hpux.
Richard M. Stallman <rms@gnu.org>
parents: 3027
diff changeset
58 #ifndef hpux
2205
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
59 /* These declarations are omitted on some systems, like Ultrix. */
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
60 extern double logb ();
3094
4b3770f84aa7 (logb): Don't declare if hpux.
Richard M. Stallman <rms@gnu.org>
parents: 3027
diff changeset
61 #endif
2205
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
62
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
63 #if defined(DOMAIN) && defined(SING) && defined(OVERFLOW)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
64 /* If those are defined, then this is probably a `matherr' machine. */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
65 # ifndef HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
66 # define HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
67 # endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
68 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
69
3027
7ed290bef028 Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents: 3025
diff changeset
70 #ifdef NO_MATHERR
3025
d09f68ccd145 [NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
71 #undef HAVE_MATHERR
d09f68ccd145 [NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
72 #endif
d09f68ccd145 [NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
73
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
74 #ifdef HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
75 # ifdef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
76 # undef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
77 # endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
78 # ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
79 # undef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
80 # endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
81 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
82
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
83 #ifndef NO_FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
84 #define FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
85 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
86
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
87 #ifdef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
88 # include <errno.h>
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
89
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
90 extern int errno;
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
91 #endif
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
92
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
93 /* Avoid traps on VMS from sinh and cosh.
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
94 All the other functions set errno instead. */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
95
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
96 #ifdef VMS
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
97 #undef cosh
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
98 #undef sinh
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
99 #define cosh(x) ((exp(x)+exp(-x))*0.5)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
100 #define sinh(x) ((exp(x)-exp(-x))*0.5)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
101 #endif /* VMS */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
102
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
103 #ifndef HAVE_RINT
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
104 #define rint(x) (floor((x)+0.5))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
105 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
106
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
107 static SIGTYPE float_error ();
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
108
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
109 /* Nonzero while executing in floating point.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
110 This tells float_error what to do. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
111
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
112 static int in_float;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
113
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
114 /* If an argument is out of range for a mathematical function,
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
115 here is the actual argument value to use in the error message. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
116
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
117 static Lisp_Object float_error_arg, float_error_arg2;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
118
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
119 static char *float_error_fn_name;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
120
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
121 /* Evaluate the floating point expression D, recording NUM
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
122 as the original argument for error messages.
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
123 D is normally an assignment expression.
1918
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
124 Handle errors which may result in signals or may set errno.
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
125
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
126 Note that float_error may be declared to return void, so you can't
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
127 just cast the zero after the colon to (SIGTYPE) to make the types
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
128 check properly. */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
129
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
130 #ifdef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
131 #define IN_FLOAT(d, name, num) \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
132 do { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
133 float_error_arg = num; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
134 float_error_fn_name = name; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
135 in_float = 1; errno = 0; (d); in_float = 0; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
136 switch (errno) { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
137 case 0: break; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
138 case EDOM: domain_error (float_error_fn_name, float_error_arg); \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
139 case ERANGE: range_error (float_error_fn_name, float_error_arg); \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
140 default: arith_error (float_error_fn_name, float_error_arg); \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
141 } \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
142 } while (0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
143 #define IN_FLOAT2(d, name, num, num2) \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
144 do { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
145 float_error_arg = num; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
146 float_error_arg2 = num2; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
147 float_error_fn_name = name; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
148 in_float = 1; errno = 0; (d); in_float = 0; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
149 switch (errno) { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
150 case 0: break; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
151 case EDOM: domain_error (float_error_fn_name, float_error_arg); \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
152 case ERANGE: range_error (float_error_fn_name, float_error_arg); \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
153 default: arith_error (float_error_fn_name, float_error_arg); \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
154 } \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
155 } while (0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
156 #else
3407
d00aaf536bfd [!FLOAT_CHECK_ERRNO] (IN_FLOAT): New definition.
Richard M. Stallman <rms@gnu.org>
parents: 3094
diff changeset
157 #define IN_FLOAT(d, name, num) (in_float = 1, (d), in_float = 0)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
158 #define IN_FLOAT2(d, name, num, num2) (in_float = 1, (d), in_float = 0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
159 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
160
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
161 #define arith_error(op,arg) \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
162 Fsignal (Qarith_error, Fcons (build_string ((op)), Fcons ((arg), Qnil)))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
163 #define range_error(op,arg) \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
164 Fsignal (Qrange_error, Fcons (build_string ((op)), Fcons ((arg), Qnil)))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
165 #define domain_error(op,arg) \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
166 Fsignal (Qdomain_error, Fcons (build_string ((op)), Fcons ((arg), Qnil)))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
167 #define domain_error2(op,a1,a2) \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
168 Fsignal (Qdomain_error, Fcons (build_string ((op)), Fcons ((a1), Fcons ((a2), Qnil))))
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
169
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
170 /* Extract a Lisp number as a `double', or signal an error. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
171
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
172 double
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
173 extract_float (num)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
174 Lisp_Object num;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
175 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
176 CHECK_NUMBER_OR_FLOAT (num, 0);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
177
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
178 if (XTYPE (num) == Lisp_Float)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
179 return XFLOAT (num)->data;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
180 return (double) XINT (num);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
181 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
182
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
183 /* Trig functions. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
184
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
185 DEFUN ("acos", Facos, Sacos, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
186 "Return the inverse cosine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
187 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
188 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
189 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
190 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
191 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
192 if (d > 1.0 || d < -1.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
193 domain_error ("acos", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
194 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
195 IN_FLOAT (d = acos (d), "acos", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
196 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
197 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
198
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
199 DEFUN ("asin", Fasin, Sasin, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
200 "Return the inverse sine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
201 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
202 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
203 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
204 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
205 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
206 if (d > 1.0 || d < -1.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
207 domain_error ("asin", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
208 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
209 IN_FLOAT (d = asin (d), "asin", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
210 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
211 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
212
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
213 DEFUN ("atan", Fatan, Satan, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
214 "Return the inverse tangent of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
215 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
216 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
217 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
218 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
219 IN_FLOAT (d = atan (d), "atan", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
220 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
221 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
222
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
223 DEFUN ("cos", Fcos, Scos, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
224 "Return the cosine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
225 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
226 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
227 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
228 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
229 IN_FLOAT (d = cos (d), "cos", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
230 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
231 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
232
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
233 DEFUN ("sin", Fsin, Ssin, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
234 "Return the sine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
235 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
236 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
237 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
238 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
239 IN_FLOAT (d = sin (d), "sin", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
240 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
241 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
242
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
243 DEFUN ("tan", Ftan, Stan, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
244 "Return the tangent of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
245 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
246 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
247 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
248 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
249 double c = cos (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
250 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
251 if (c == 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
252 domain_error ("tan", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
253 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
254 IN_FLOAT (d = sin (d) / c, "tan", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
255 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
256 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
257
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
258 #if 0 /* Leave these out unless we find there's a reason for them. */
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
259
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
260 DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
261 "Return the bessel function j0 of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
262 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
263 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
264 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
265 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
266 IN_FLOAT (d = j0 (d), "bessel-j0", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
267 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
268 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
269
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
270 DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
271 "Return the bessel function j1 of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
272 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
273 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
274 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
275 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
276 IN_FLOAT (d = j1 (d), "bessel-j1", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
277 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
278 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
279
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
280 DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
281 "Return the order N bessel function output jn of ARG.\n\
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
282 The first arg (the order) is truncated to an integer.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
283 (arg1, arg2)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
284 register Lisp_Object arg1, arg2;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
285 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
286 int i1 = extract_float (arg1);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
287 double f2 = extract_float (arg2);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
288
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
289 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", arg1);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
290 return make_float (f2);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
291 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
292
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
293 DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
294 "Return the bessel function y0 of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
295 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
296 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
297 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
298 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
299 IN_FLOAT (d = y0 (d), "bessel-y0", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
300 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
301 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
302
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
303 DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
304 "Return the bessel function y1 of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
305 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
306 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
307 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
308 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
309 IN_FLOAT (d = y1 (d), "bessel-y0", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
310 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
311 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
312
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
313 DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
314 "Return the order N bessel function output yn of ARG.\n\
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
315 The first arg (the order) is truncated to an integer.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
316 (arg1, arg2)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
317 register Lisp_Object arg1, arg2;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
318 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
319 int i1 = extract_float (arg1);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
320 double f2 = extract_float (arg2);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
321
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
322 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", arg1);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
323 return make_float (f2);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
324 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
325
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
326 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
327
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
328 #if 0 /* Leave these out unless we see they are worth having. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
329
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
330 DEFUN ("erf", Ferf, Serf, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
331 "Return the mathematical error function of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
332 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
333 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
334 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
335 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
336 IN_FLOAT (d = erf (d), "erf", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
337 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
338 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
339
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
340 DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
341 "Return the complementary error function of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
342 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
343 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
344 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
345 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
346 IN_FLOAT (d = erfc (d), "erfc", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
347 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
348 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
349
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
350 DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
351 "Return the log gamma of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
352 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
353 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
354 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
355 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
356 IN_FLOAT (d = lgamma (d), "log-gamma", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
357 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
358 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
359
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
360 DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
361 "Return the cube root of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
362 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
363 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
364 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
365 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
366 #ifdef HAVE_CBRT
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
367 IN_FLOAT (d = cbrt (d), "cube-root", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
368 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
369 if (d >= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
370 IN_FLOAT (d = pow (d, 1.0/3.0), "cube-root", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
371 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
372 IN_FLOAT (d = -pow (-d, 1.0/3.0), "cube-root", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
373 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
374 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
375 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
376
694
714b8017cc6b entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 683
diff changeset
377 #endif
714b8017cc6b entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 683
diff changeset
378
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
379 DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
380 "Return the exponential base e of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
381 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
382 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
383 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
384 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
385 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
386 if (d > 709.7827) /* Assume IEEE doubles here */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
387 range_error ("exp", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
388 else if (d < -709.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
389 return make_float (0.0);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
390 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
391 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
392 IN_FLOAT (d = exp (d), "exp", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
393 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
394 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
395
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
396 DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
397 "Return the exponential X ** Y.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
398 (arg1, arg2)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
399 register Lisp_Object arg1, arg2;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
400 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
401 double f1, f2;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
402
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
403 CHECK_NUMBER_OR_FLOAT (arg1, 0);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
404 CHECK_NUMBER_OR_FLOAT (arg2, 0);
4529
8dc73bbe1c46 (Fexpt): Use IN_FLOAT2.
Richard M. Stallman <rms@gnu.org>
parents: 4506
diff changeset
405 if (XTYPE (arg1) == Lisp_Int /* common lisp spec */
8dc73bbe1c46 (Fexpt): Use IN_FLOAT2.
Richard M. Stallman <rms@gnu.org>
parents: 4506
diff changeset
406 && XTYPE (arg2) == Lisp_Int) /* don't promote, if both are ints */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
407 { /* this can be improved by pre-calculating */
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3546
diff changeset
408 int acc, x, y; /* some binary powers of x then accumulating */
3673
8ab0a7453577 (Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
409 Lisp_Object val;
8ab0a7453577 (Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
410
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
411 x = XINT (arg1);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
412 y = XINT (arg2);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
413 acc = 1;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
414
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
415 if (y < 0)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
416 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
417 if (x == 1)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
418 acc = 1;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
419 else if (x == -1)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
420 acc = (y & 1) ? -1 : 1;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
421 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
422 acc = 0;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
423 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
424 else
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
425 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
426 for (; y > 0; y--)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
427 while (y > 0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
428 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
429 if (y & 1)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
430 acc *= x;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
431 x *= x;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
432 y = (unsigned)y >> 1;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
433 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
434 }
3673
8ab0a7453577 (Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
435 XSET (val, Lisp_Int, acc);
8ab0a7453577 (Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
436 return val;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
437 }
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
438 f1 = (XTYPE (arg1) == Lisp_Float) ? XFLOAT (arg1)->data : XINT (arg1);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
439 f2 = (XTYPE (arg2) == Lisp_Float) ? XFLOAT (arg2)->data : XINT (arg2);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
440 /* Really should check for overflow, too */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
441 if (f1 == 0.0 && f2 == 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
442 f1 = 1.0;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
443 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
444 else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor(f2)))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
445 domain_error2 ("expt", arg1, arg2);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
446 #endif
4529
8dc73bbe1c46 (Fexpt): Use IN_FLOAT2.
Richard M. Stallman <rms@gnu.org>
parents: 4506
diff changeset
447 IN_FLOAT2 (f1 = pow (f1, f2), "expt", arg1, arg2);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
448 return make_float (f1);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
449 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
450
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
451 DEFUN ("log", Flog, Slog, 1, 2, 0,
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
452 "Return the natural logarithm of ARG.\n\
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
453 If second optional argument BASE is given, return log ARG using that base.")
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
454 (arg, base)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
455 register Lisp_Object arg, base;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
456 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
457 double d = extract_float (arg);
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
458
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
459 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
460 if (d <= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
461 domain_error2 ("log", arg, base);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
462 #endif
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
463 if (NILP (base))
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
464 IN_FLOAT (d = log (d), "log", arg);
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
465 else
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
466 {
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
467 double b = extract_float (base);
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
468
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
469 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
470 if (b <= 0.0 || b == 1.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
471 domain_error2 ("log", arg, base);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
472 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
473 if (b == 10.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
474 IN_FLOAT2 (d = log10 (d), "log", arg, base);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
475 else
3407
d00aaf536bfd [!FLOAT_CHECK_ERRNO] (IN_FLOAT): New definition.
Richard M. Stallman <rms@gnu.org>
parents: 3094
diff changeset
476 IN_FLOAT2 (d = log (d) / log (b), "log", arg, base);
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
477 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
478 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
479 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
480
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
481 DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
482 "Return the logarithm base 10 of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
483 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
484 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
485 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
486 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
487 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
488 if (d <= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
489 domain_error ("log10", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
490 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
491 IN_FLOAT (d = log10 (d), "log10", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
492 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
493 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
494
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
495 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
496 "Return the square root of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
497 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
498 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
499 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
500 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
501 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
502 if (d < 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
503 domain_error ("sqrt", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
504 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
505 IN_FLOAT (d = sqrt (d), "sqrt", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
506 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
507 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
508
694
714b8017cc6b entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 683
diff changeset
509 #if 0 /* Not clearly worth adding. */
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
510
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
511 DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
512 "Return the inverse hyperbolic cosine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
513 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
514 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
515 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
516 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
517 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
518 if (d < 1.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
519 domain_error ("acosh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
520 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
521 #ifdef HAVE_INVERSE_HYPERBOLIC
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
522 IN_FLOAT (d = acosh (d), "acosh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
523 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
524 IN_FLOAT (d = log (d + sqrt (d*d - 1.0)), "acosh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
525 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
526 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
527 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
528
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
529 DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
530 "Return the inverse hyperbolic sine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
531 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
532 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
533 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
534 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
535 #ifdef HAVE_INVERSE_HYPERBOLIC
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
536 IN_FLOAT (d = asinh (d), "asinh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
537 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
538 IN_FLOAT (d = log (d + sqrt (d*d + 1.0)), "asinh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
539 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
540 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
541 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
542
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
543 DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
544 "Return the inverse hyperbolic tangent of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
545 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
546 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
547 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
548 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
549 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
550 if (d >= 1.0 || d <= -1.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
551 domain_error ("atanh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
552 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
553 #ifdef HAVE_INVERSE_HYPERBOLIC
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
554 IN_FLOAT (d = atanh (d), "atanh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
555 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
556 IN_FLOAT (d = 0.5 * log ((1.0 + d) / (1.0 - d)), "atanh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
557 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
558 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
559 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
560
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
561 DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
562 "Return the hyperbolic cosine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
563 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
564 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
565 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
566 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
567 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
568 if (d > 710.0 || d < -710.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
569 range_error ("cosh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
570 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
571 IN_FLOAT (d = cosh (d), "cosh", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
572 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
573 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
574
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
575 DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
576 "Return the hyperbolic sine of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
577 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
578 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
579 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
580 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
581 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
582 if (d > 710.0 || d < -710.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
583 range_error ("sinh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
584 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
585 IN_FLOAT (d = sinh (d), "sinh", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
586 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
587 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
588
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
589 DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
590 "Return the hyperbolic tangent of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
591 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
592 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
593 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
594 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
595 IN_FLOAT (d = tanh (d), "tanh", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
596 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
597 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
598 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
599
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
600 DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
601 "Return the absolute value of ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
602 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
603 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
604 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
605 CHECK_NUMBER_OR_FLOAT (arg, 0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
606
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
607 if (XTYPE (arg) == Lisp_Float)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
608 IN_FLOAT (arg = make_float (fabs (XFLOAT (arg)->data)), "abs", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
609 else if (XINT (arg) < 0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
610 XSETINT (arg, - XFASTINT (arg));
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
611
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
612 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
613 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
614
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
615 DEFUN ("float", Ffloat, Sfloat, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
616 "Return the floating point number equal to ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
617 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
618 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
619 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
620 CHECK_NUMBER_OR_FLOAT (arg, 0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
621
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
622 if (XTYPE (arg) == Lisp_Int)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
623 return make_float ((double) XINT (arg));
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
624 else /* give 'em the same float back */
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
625 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
626 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
627
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
628 DEFUN ("logb", Flogb, Slogb, 1, 1, 0,
4590
e8bd41ac77be (Flogb): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4529
diff changeset
629 "Returns largest integer <= the base 2 log of the magnitude of ARG.\n\
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
630 This is the same as the exponent of a float.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
631 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
632 Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
633 {
2119
4077ef8ad483 * floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents: 2094
diff changeset
634 Lisp_Object val;
2129
6741f5f8ed54 (Flogb): Fix arg names. Don't confuse Lisp_Object with integer.
Richard M. Stallman <rms@gnu.org>
parents: 2128
diff changeset
635 int value;
6741f5f8ed54 (Flogb): Fix arg names. Don't confuse Lisp_Object with integer.
Richard M. Stallman <rms@gnu.org>
parents: 2128
diff changeset
636 double f = extract_float (arg);
2119
4077ef8ad483 * floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents: 2094
diff changeset
637
4501
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
638 #ifdef HAVE_LOGB
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
639 IN_FLOAT (value = logb (f), "logb", arg);
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
640 XSET (val, Lisp_Int, value);
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
641 #else
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
642 #ifdef HAVE_FREXP
2205
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
643 {
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
644 int exp;
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
645
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
646 IN_FLOAT (frexp (f, &exp), "logb", arg);
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
647 XSET (val, Lisp_Int, exp-1);
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
648 }
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
649 #else
4594
dc7eabff318b (Flogb): Error at run time if not supported.
Richard M. Stallman <rms@gnu.org>
parents: 4590
diff changeset
650 /* Would someone like to write code to emulate logb? */
dc7eabff318b (Flogb): Error at run time if not supported.
Richard M. Stallman <rms@gnu.org>
parents: 4590
diff changeset
651 error ("`logb' not implemented on this operating system");
4501
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
652 #endif
2205
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
653 #endif
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
654
2119
4077ef8ad483 * floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents: 2094
diff changeset
655 return val;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
656 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
657
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
658 /* the rounding functions */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
659
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
660 DEFUN ("ceiling", Fceiling, Sceiling, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
661 "Return the smallest integer no less than ARG. (Round toward +inf.)")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
662 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
663 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
664 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
665 CHECK_NUMBER_OR_FLOAT (arg, 0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
666
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
667 if (XTYPE (arg) == Lisp_Float)
3546
1950b2238ecc (Fceiling): Fix spelling of "ceiling".
Richard M. Stallman <rms@gnu.org>
parents: 3407
diff changeset
668 IN_FLOAT (XSET (arg, Lisp_Int, ceil (XFLOAT (arg)->data)), "ceiling", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
669
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
670 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
671 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
672
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
673 #endif /* LISP_FLOAT_TYPE */
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
674
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
675
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
676 DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0,
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
677 "Return the largest integer no greater than ARG. (Round towards -inf.)\n\
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
678 With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR.")
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
679 (arg, divisor)
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
680 register Lisp_Object arg, divisor;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
681 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
682 CHECK_NUMBER_OR_FLOAT (arg, 0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
683
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
684 if (! NILP (divisor))
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
685 {
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
686 int i1, i2;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
687
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
688 CHECK_NUMBER_OR_FLOAT (divisor, 1);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
689
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
690 #ifdef LISP_FLOAT_TYPE
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
691 if (XTYPE (arg) == Lisp_Float || XTYPE (divisor) == Lisp_Float)
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
692 {
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
693 double f1, f2;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
694
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
695 f1 = XTYPE (arg) == Lisp_Float ? XFLOAT (arg)->data : XINT (arg);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
696 f2 = (XTYPE (divisor) == Lisp_Float
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
697 ? XFLOAT (divisor)->data : XINT (divisor));
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
698 if (f2 == 0)
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
699 Fsignal (Qarith_error, Qnil);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
700
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
701 IN_FLOAT2 (XSET (arg, Lisp_Int, floor (f1 / f2)),
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
702 "floor", arg, divisor);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
703 return arg;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
704 }
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
705 #endif
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
706
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
707 i1 = XINT (arg);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
708 i2 = XINT (divisor);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
709
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
710 if (i2 == 0)
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
711 Fsignal (Qarith_error, Qnil);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
712
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
713 /* With C's /, the result is implementation-defined if either operand
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
714 is negative, so use only nonnegative operands. */
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
715 i1 = (i2 < 0
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
716 ? (i1 <= 0 ? -i1 / -i2 : -1 - ((i1 - 1) / -i2))
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
717 : (i1 < 0 ? -1 - ((-1 - i1) / i2) : i1 / i2));
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
718
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
719 XSET (arg, Lisp_Int, i1);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
720 return arg;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
721 }
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
722
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
723 #ifdef LISP_FLOAT_TYPE
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
724 if (XTYPE (arg) == Lisp_Float)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
725 IN_FLOAT (XSET (arg, Lisp_Int, floor (XFLOAT (arg)->data)), "floor", arg);
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
726 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
727
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
728 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
729 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
730
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
731 #ifdef LISP_FLOAT_TYPE
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
732
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
733 DEFUN ("round", Fround, Sround, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
734 "Return the nearest integer to ARG.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
735 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
736 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
737 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
738 CHECK_NUMBER_OR_FLOAT (arg, 0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
739
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
740 if (XTYPE (arg) == Lisp_Float)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
741 /* Screw the prevailing rounding mode. */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
742 IN_FLOAT (XSET (arg, Lisp_Int, rint (XFLOAT (arg)->data)), "round", arg);
1918
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
743
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
744 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
745 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
746
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
747 DEFUN ("truncate", Ftruncate, Struncate, 1, 1, 0,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
748 "Truncate a floating point number to an int.\n\
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
749 Rounds the value toward zero.")
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
750 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
751 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
752 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
753 CHECK_NUMBER_OR_FLOAT (arg, 0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
754
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
755 if (XTYPE (arg) == Lisp_Float)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
756 XSET (arg, Lisp_Int, (int) XFLOAT (arg)->data);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
757
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
758 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
759 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
760
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
761 #if 0
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
762 /* It's not clear these are worth adding. */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
763
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
764 DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0,
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
765 "Return the smallest integer no less than ARG, as a float.\n\
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
766 \(Round toward +inf.\)")
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
767 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
768 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
769 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
770 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
771 IN_FLOAT (d = ceil (d), "fceiling", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
772 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
773 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
774
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
775 DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0,
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
776 "Return the largest integer no greater than ARG, as a float.\n\
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
777 \(Round towards -inf.\)")
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
778 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
779 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
780 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
781 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
782 IN_FLOAT (d = floor (d), "ffloor", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
783 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
784 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
785
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
786 DEFUN ("fround", Ffround, Sfround, 1, 1, 0,
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
787 "Return the nearest integer to ARG, as a float.")
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
788 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
789 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
790 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
791 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
792 IN_FLOAT (d = rint (XFLOAT (arg)->data), "fround", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
793 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
794 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
795
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
796 DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0,
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
797 "Truncate a floating point number to an integral float value.\n\
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
798 Rounds the value toward zero.")
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
799 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
800 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
801 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
802 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
803 if (d >= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
804 IN_FLOAT (d = floor (d), "ftruncate", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
805 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
806 IN_FLOAT (d = ceil (d), arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
807 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
808 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
809 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
810
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
811 #ifdef FLOAT_CATCH_SIGILL
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
812 static SIGTYPE
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
813 float_error (signo)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
814 int signo;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
815 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
816 if (! in_float)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
817 fatal_error_signal (signo);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
818
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
819 #ifdef BSD
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
820 #ifdef BSD4_1
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
821 sigrelse (SIGILL);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
822 #else /* not BSD4_1 */
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
823 sigsetmask (SIGEMPTYMASK);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
824 #endif /* not BSD4_1 */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
825 #else
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
826 /* Must reestablish handler each time it is called. */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
827 signal (SIGILL, float_error);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
828 #endif /* BSD */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
829
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
830 in_float = 0;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
831
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
832 Fsignal (Qarith_error, Fcons (float_error_arg, Qnil));
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
833 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
834
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
835 /* Another idea was to replace the library function `infnan'
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
836 where SIGILL is signaled. */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
837
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
838 #endif /* FLOAT_CATCH_SIGILL */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
839
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
840 #ifdef HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
841 int
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
842 matherr (x)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
843 struct exception *x;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
844 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
845 Lisp_Object args;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
846 if (! in_float)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
847 /* Not called from emacs-lisp float routines; do the default thing. */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
848 return 0;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
849 if (!strcmp (x->name, "pow"))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
850 x->name = "expt";
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
851
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
852 args
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
853 = Fcons (build_string (x->name),
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
854 Fcons (make_float (x->arg1),
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
855 ((!strcmp (x->name, "log") || !strcmp (x->name, "pow"))
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
856 ? Fcons (make_float (x->arg2), Qnil)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
857 : Qnil)));
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
858 switch (x->type)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
859 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
860 case DOMAIN: Fsignal (Qdomain_error, args); break;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
861 case SING: Fsignal (Qsingularity_error, args); break;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
862 case OVERFLOW: Fsignal (Qoverflow_error, args); break;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
863 case UNDERFLOW: Fsignal (Qunderflow_error, args); break;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
864 default: Fsignal (Qarith_error, args); break;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
865 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
866 return (1); /* don't set errno or print a message */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
867 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
868 #endif /* HAVE_MATHERR */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
869
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
870 init_floatfns ()
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
871 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
872 #ifdef FLOAT_CATCH_SIGILL
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
873 signal (SIGILL, float_error);
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
874 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
875 in_float = 0;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
876 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
877
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
878 #else /* not LISP_FLOAT_TYPE */
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
879
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
880 init_floatfns ()
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
881 {}
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
882
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
883 #endif /* not LISP_FLOAT_TYPE */
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
884
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
885 syms_of_floatfns ()
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
886 {
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
887 #ifdef LISP_FLOAT_TYPE
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
888 defsubr (&Sacos);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
889 defsubr (&Sasin);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
890 defsubr (&Satan);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
891 defsubr (&Scos);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
892 defsubr (&Ssin);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
893 defsubr (&Stan);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
894 #if 0
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
895 defsubr (&Sacosh);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
896 defsubr (&Sasinh);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
897 defsubr (&Satanh);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
898 defsubr (&Scosh);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
899 defsubr (&Ssinh);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
900 defsubr (&Stanh);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
901 defsubr (&Sbessel_y0);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
902 defsubr (&Sbessel_y1);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
903 defsubr (&Sbessel_yn);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
904 defsubr (&Sbessel_j0);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
905 defsubr (&Sbessel_j1);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
906 defsubr (&Sbessel_jn);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
907 defsubr (&Serf);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
908 defsubr (&Serfc);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
909 defsubr (&Slog_gamma);
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
910 defsubr (&Scube_root);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
911 defsubr (&Sfceiling);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
912 defsubr (&Sffloor);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
913 defsubr (&Sfround);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
914 defsubr (&Sftruncate);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
915 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
916 defsubr (&Sexp);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
917 defsubr (&Sexpt);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
918 defsubr (&Slog);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
919 defsubr (&Slog10);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
920 defsubr (&Ssqrt);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
921
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
922 defsubr (&Sabs);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
923 defsubr (&Sfloat);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
924 defsubr (&Slogb);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
925 defsubr (&Sceiling);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
926 defsubr (&Sround);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
927 defsubr (&Struncate);
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
928 #endif /* LISP_FLOAT_TYPE */
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
929 defsubr (&Sfloor);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
930 }