annotate src/floatfns.c @ 282:c42ec1d1cded r21-0b39

Import from CVS: tag r21-0b39
author cvs
date Mon, 13 Aug 2007 10:33:18 +0200
parents c5d627a313b1
children 558f606b08ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Primitive operations on floating point for XEmacs Lisp interpreter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* ANSI C requires only these float functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, tan, tanh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 Define HAVE_INVERSE_HYPERBOLIC if you have acosh, asinh, and atanh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 Define HAVE_CBRT if you have cbrt().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 Define HAVE_RINT if you have rint().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 If you don't define these, then the appropriate routines will be simulated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 Define HAVE_MATHERR if on a system supporting the SysV matherr() callback.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (This should happen automatically.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 Define FLOAT_CHECK_ERRNO if the float library routines set errno.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 This has no effect if HAVE_MATHERR is defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Define FLOAT_CATCH_SIGILL if the float library routines signal SIGILL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (What systems actually do this? Let me know. -jwz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 Define FLOAT_CHECK_DOMAIN if the float library doesn't handle errors by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 either setting errno, or signalling SIGFPE/SIGILL. Otherwise, domain and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 range checking will happen before calling the float routines. This has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 no effect if HAVE_MATHERR is defined (since matherr will be called when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 a domain error occurs).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 #include "syssignal.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 /* Need to define a differentiating symbol -- see sysfloat.h */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #define THIS_FILENAME floatfns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #include "sysfloat.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #ifndef HAVE_RINT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 static double
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 rint (double x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 double r = floor (x + 0.5);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 double diff = fabs (r - x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 /* Round to even and correct for any roundoff errors. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 if (diff >= 0.5 && (diff > 0.5 || r != 2.0 * floor (r / 2.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 r += r < x ? 1.0 : -1.0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 return r;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 /* Nonzero while executing in floating point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 This tells float_error what to do. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 static int in_float;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 /* If an argument is out of range for a mathematical function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 here is the actual argument value to use in the error message. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 static Lisp_Object float_error_arg, float_error_arg2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 static CONST char *float_error_fn_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 /* Evaluate the floating point expression D, recording NUM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 as the original argument for error messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 D is normally an assignment expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Handle errors which may result in signals or may set errno.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Note that float_error may be declared to return void, so you can't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 just cast the zero after the colon to (SIGTYPE) to make the types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 check properly. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 #ifdef FLOAT_CHECK_ERRNO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 #define IN_FLOAT(d, name, num) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 float_error_arg = num; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 float_error_fn_name = name; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 in_float = 1; errno = 0; (d); in_float = 0; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 if (errno != 0) in_float_error (); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 #define IN_FLOAT2(d, name, num, num2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 float_error_arg = num; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 float_error_arg2 = num2; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 float_error_fn_name = name; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 in_float = 2; errno = 0; (d); in_float = 0; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 if (errno != 0) in_float_error (); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 #define IN_FLOAT(d, name, num) (in_float = 1, (d), in_float = 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 #define IN_FLOAT2(d, name, num, num2) (in_float = 2, (d), in_float = 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 #define arith_error(op,arg) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 Fsignal (Qarith_error, list2 (build_string ((op)), (arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 #define range_error(op,arg) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 Fsignal (Qrange_error, list2 (build_string ((op)), (arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 #define range_error2(op,a1,a2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Fsignal (Qrange_error, list3 (build_string ((op)), (a1), (a2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 #define domain_error(op,arg) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Fsignal (Qdomain_error, list2 (build_string ((op)), (arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 #define domain_error2(op,a1,a2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 Fsignal (Qdomain_error, list3 (build_string ((op)), (a1), (a2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
122 /* Convert float to Lisp Integer if it fits, else signal a range
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
123 error using the given arguments. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 float_to_int (double x, CONST char *name, Lisp_Object num, Lisp_Object num2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 if (x >= ((EMACS_INT) 1 << (VALBITS-1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 || x <= - ((EMACS_INT) 1 << (VALBITS-1)) - (EMACS_INT) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 if (!UNBOUNDP (num2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 range_error2 (name, num, num2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 range_error (name, num);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 return (make_int ((EMACS_INT) x));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 in_float_error (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 switch (errno)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
144 case 0:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 case EDOM:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 if (in_float == 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 domain_error2 (float_error_fn_name, float_error_arg, float_error_arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 domain_error (float_error_fn_name, float_error_arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 case ERANGE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 range_error (float_error_fn_name, float_error_arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 arith_error (float_error_fn_name, float_error_arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 mark_float (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 return (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 float_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 return (extract_float (o1) == extract_float (o2));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 float_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 /* mod the value down to 32-bit range */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 /* #### change for 64-bit machines */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 return (unsigned long) fmod (extract_float (obj), 4e9);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
182 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("float", float,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
183 mark_float, print_float, 0, float_equal,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
184 float_hash, struct Lisp_Float);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 /* Extract a Lisp number as a `double', or signal an error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 double
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 extract_float (Lisp_Object num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 CHECK_INT_OR_FLOAT (num);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 if (FLOATP (num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 return (float_data (XFLOAT (num)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 return (double) XINT (num);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 /* Trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
203 DEFUN ("acos", Facos, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 Return the inverse cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
205 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
206 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 if (d > 1.0 || d < -1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 domain_error ("acos", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 IN_FLOAT (d = acos (d), "acos", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
217 DEFUN ("asin", Fasin, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Return the inverse sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
219 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
220 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 if (d > 1.0 || d < -1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 domain_error ("asin", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 IN_FLOAT (d = asin (d), "asin", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
231 DEFUN ("atan", Fatan, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 Return the inverse tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
233 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
234 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 double d = extract_float (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 if (NILP (arg2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 IN_FLOAT (d = atan (d), "atan", arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 double d2 = extract_float (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 if (d == 0.0 && d2 == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 domain_error2 ("atan", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 IN_FLOAT2 (d = atan2 (d, d2), "atan", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
252 DEFUN ("cos", Fcos, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Return the cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
254 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
255 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 IN_FLOAT (d = cos (d), "cos", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
262 DEFUN ("sin", Fsin, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 Return the sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
264 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
265 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 IN_FLOAT (d = sin (d), "sin", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
272 DEFUN ("tan", Ftan, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 Return the tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
274 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
275 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 double c = cos (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 if (c == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 domain_error ("tan", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 IN_FLOAT (d = (sin (d) / c), "tan", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 #endif /* LISP_FLOAT_TYPE (trig functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 /* Bessel functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 #if 0 /* Leave these out unless we find there's a reason for them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 /* #ifdef LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
293 DEFUN ("bessel-j0", Fbessel_j0, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 Return the bessel function j0 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
295 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
296 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 IN_FLOAT (d = j0 (d), "bessel-j0", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
303 DEFUN ("bessel-j1", Fbessel_j1, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 Return the bessel function j1 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
305 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
306 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 IN_FLOAT (d = j1 (d), "bessel-j1", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
313 DEFUN ("bessel-jn", Fbessel_jn, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 Return the order N bessel function output jn of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 The first arg (the order) is truncated to an integer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
316 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
317 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 int i1 = extract_float (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 double f2 = extract_float (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 return make_float (f2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
326 DEFUN ("bessel-y0", Fbessel_y0, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 Return the bessel function y0 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
328 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
329 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 IN_FLOAT (d = y0 (d), "bessel-y0", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
336 DEFUN ("bessel-y1", Fbessel_y1, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 Return the bessel function y1 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
338 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
339 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 IN_FLOAT (d = y1 (d), "bessel-y0", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
346 DEFUN ("bessel-yn", Fbessel_yn, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 Return the order N bessel function output yn of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 The first arg (the order) is truncated to an integer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
349 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
350 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 int i1 = extract_float (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 double f2 = extract_float (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 return make_float (f2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 #endif /* 0 (bessel functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 /* Error functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 #if 0 /* Leave these out unless we see they are worth having. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 /* #ifdef LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
365 DEFUN ("erf", Ferf, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Return the mathematical error function of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
367 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
368 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 IN_FLOAT (d = erf (d), "erf", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
375 DEFUN ("erfc", Ferfc, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 Return the complementary error function of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
377 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
378 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 IN_FLOAT (d = erfc (d), "erfc", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
385 DEFUN ("log-gamma", Flog_gamma, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 Return the log gamma of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
387 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
388 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 IN_FLOAT (d = lgamma (d), "log-gamma", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 #endif /* 0 (error functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 /* Root and Log functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
401 DEFUN ("exp", Fexp, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 Return the exponential base e of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
403 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
404 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 if (d > 709.7827) /* Assume IEEE doubles here */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 range_error ("exp", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 else if (d < -709.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 return make_float (0.0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 IN_FLOAT (d = exp (d), "exp", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
420 DEFUN ("expt", Fexpt, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 Return the exponential ARG1 ** ARG2.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
422 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
423 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 double f1, f2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 CHECK_INT_OR_FLOAT (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 CHECK_INT_OR_FLOAT (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 if ((INTP (arg1)) && /* common lisp spec */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (INTP (arg2))) /* don't promote, if both are ints */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 EMACS_INT acc, x, y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 x = XINT (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 y = XINT (arg2);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
435
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 if (y < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 if (x == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 acc = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 else if (x == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 acc = (y & 1) ? -1 : 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 acc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 acc = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 while (y > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 if (y & 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 acc *= x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 x *= x;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
453 y = (EMACS_UINT) y >> 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 return (make_int (acc));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 f1 = (FLOATP (arg1)) ? float_data (XFLOAT (arg1)) : XINT (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 f2 = (FLOATP (arg2)) ? float_data (XFLOAT (arg2)) : XINT (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 /* Really should check for overflow, too */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 if (f1 == 0.0 && f2 == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 f1 = 1.0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 # ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor(f2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 domain_error2 ("expt", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 # endif /* FLOAT_CHECK_DOMAIN */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 IN_FLOAT2 (f1 = pow (f1, f2), "expt", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 return make_float (f1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 #else /* !LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
476 DEFUN ("log", Flog, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 Return the natural logarithm of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 If second optional argument BASE is given, return log ARG using that base.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
479 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
480 (arg, base))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (d <= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 domain_error2 ("log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 if (NILP (base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 IN_FLOAT (d = log (d), "log", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 double b = extract_float (base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 if (b <= 0.0 || b == 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 domain_error2 ("log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 if (b == 10.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 IN_FLOAT2 (d = log10 (d), "log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 IN_FLOAT2 (d = (log (d) / log (b)), "log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
505 DEFUN ("log10", Flog10, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 Return the logarithm base 10 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
507 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
508 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 if (d <= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 domain_error ("log10", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 IN_FLOAT (d = log10 (d), "log10", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
520 DEFUN ("sqrt", Fsqrt, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 Return the square root of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
522 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
523 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 if (d < 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 domain_error ("sqrt", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 IN_FLOAT (d = sqrt (d), "sqrt", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
535 DEFUN ("cube-root", Fcube_root, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 Return the cube root of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
537 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
538 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 #ifdef HAVE_CBRT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 IN_FLOAT (d = cbrt (d), "cube-root", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 if (d >= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 IN_FLOAT (d = pow (d, 1.0/3.0), "cube-root", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 IN_FLOAT (d = -pow (-d, 1.0/3.0), "cube-root", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 /* Inverse trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 /* #if 0 Not clearly worth adding... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
558 DEFUN ("acosh", Facosh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 Return the inverse hyperbolic cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
560 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
561 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (d < 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 domain_error ("acosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 #ifdef HAVE_INVERSE_HYPERBOLIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 IN_FLOAT (d = acosh (d), "acosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 IN_FLOAT (d = log (d + sqrt (d*d - 1.0)), "acosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
576 DEFUN ("asinh", Fasinh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 Return the inverse hyperbolic sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
578 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
579 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 #ifdef HAVE_INVERSE_HYPERBOLIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 IN_FLOAT (d = asinh (d), "asinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 IN_FLOAT (d = log (d + sqrt (d*d + 1.0)), "asinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
590 DEFUN ("atanh", Fatanh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 Return the inverse hyperbolic tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
592 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
593 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 if (d >= 1.0 || d <= -1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 domain_error ("atanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 #ifdef HAVE_INVERSE_HYPERBOLIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 IN_FLOAT (d = atanh (d), "atanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 IN_FLOAT (d = 0.5 * log ((1.0 + d) / (1.0 - d)), "atanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
608 DEFUN ("cosh", Fcosh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 Return the hyperbolic cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
610 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
611 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 if (d > 710.0 || d < -710.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 range_error ("cosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 IN_FLOAT (d = cosh (d), "cosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
622 DEFUN ("sinh", Fsinh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 Return the hyperbolic sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
624 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
625 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 if (d > 710.0 || d < -710.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 range_error ("sinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 IN_FLOAT (d = sinh (d), "sinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
636 DEFUN ("tanh", Ftanh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 Return the hyperbolic tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
638 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
639 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 IN_FLOAT (d = tanh (d), "tanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 #endif /* LISP_FLOAT_TYPE (inverse trig functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 /* Rounding functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
649 DEFUN ("abs", Fabs, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 Return the absolute value of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
651 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
652 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 IN_FLOAT (arg = make_float ((double) fabs (float_data (XFLOAT (arg)))),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "abs", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 return (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 if (XINT (arg) < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 return (make_int (- XINT (arg)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 return (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
672 DEFUN ("float", Ffloat, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 Return the floating point number equal to ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
674 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
675 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 if (INTP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 return make_float ((double) XINT (arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 else /* give 'em the same float back */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
688 DEFUN ("logb", Flogb, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 Return largest integer <= the base 2 log of the magnitude of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 This is the same as the exponent of a float.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
691 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
692 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 double f = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 if (f == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 return (make_int (- (((EMACS_UINT) 1) << (VALBITS - 1)))); /* most-negative-fixnum */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 #ifdef HAVE_LOGB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 Lisp_Object val;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
701 IN_FLOAT (val = make_int ((int) logb (f)), "logb", arg);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 return (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 #ifdef HAVE_FREXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
707 int exqp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 IN_FLOAT (frexp (f, &exqp), "logb", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 return (make_int (exqp - 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 EMACS_INT val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 if (f < 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 f = -f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 val = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 while (f < 0.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 for (i = 1, d = 0.5; d * d >= f; i += i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 d *= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 f /= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 val -= i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 while (f >= 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 for (i = 1, d = 2.0; d * d <= f; i += i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 d *= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 f /= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 val += i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 return (make_int (val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 #endif /* ! HAVE_FREXP */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 #endif /* ! HAVE_LOGB */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
741 DEFUN ("ceiling", Fceiling, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 Return the smallest integer no less than ARG. (Round toward +inf.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
743 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
744 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 IN_FLOAT ((d = ceil (float_data (XFLOAT (arg)))), "ceiling", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 return (float_to_int (d, "ceiling", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
761 DEFUN ("floor", Ffloor, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 Return the largest integer no greater than ARG. (Round towards -inf.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
764 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
765 (arg, divisor))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 if (! NILP (divisor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 EMACS_INT i1, i2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 CHECK_INT_OR_FLOAT (divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 if (FLOATP (arg) || FLOATP (divisor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 double f1, f2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 f1 = ((FLOATP (arg)) ? float_data (XFLOAT (arg)) : XINT (arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 f2 = ((FLOATP (divisor)) ? float_data (XFLOAT (divisor)) : XINT (divisor));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 if (f2 == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 Fsignal (Qarith_error, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 IN_FLOAT2 (f1 = floor (f1 / f2), "floor", arg, divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 return float_to_int (f1, "floor", arg, divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 i1 = XINT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 i2 = XINT (divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 if (i2 == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 Fsignal (Qarith_error, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 /* With C's /, the result is implementation-defined if either operand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 is negative, so use only nonnegative operands. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 i1 = (i2 < 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ? (i1 <= 0 ? -i1 / -i2 : -1 - ((i1 - 1) / -i2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 : (i1 < 0 ? -1 - ((-1 - i1) / i2) : i1 / i2));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 return (make_int (i1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 IN_FLOAT ((d = floor (float_data (XFLOAT (arg)))), "floor", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 return (float_to_int (d, "floor", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
817 DEFUN ("round", Fround, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Return the nearest integer to ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
819 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
820 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 /* Screw the prevailing rounding mode. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 IN_FLOAT ((d = rint (float_data (XFLOAT (arg)))), "round", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 return (float_to_int (d, "round", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
837 DEFUN ("truncate", Ftruncate, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 Truncate a floating point number to an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 Rounds the value toward zero.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
840 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
841 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 return (float_to_int (float_data (XFLOAT (arg)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 "truncate", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 /* Float-rounding functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 /* #if 1 It's not clear these are worth adding... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
858 DEFUN ("fceiling", Ffceiling, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 Return the smallest integer no less than ARG, as a float.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 \(Round toward +inf.\)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
861 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
862 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 IN_FLOAT (d = ceil (d), "fceiling", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
869 DEFUN ("ffloor", Fffloor, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 Return the largest integer no greater than ARG, as a float.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 \(Round towards -inf.\)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
872 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
873 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 IN_FLOAT (d = floor (d), "ffloor", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
880 DEFUN ("fround", Ffround, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 Return the nearest integer to ARG, as a float.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
882 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
883 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 IN_FLOAT (d = rint (d), "fround", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
890 DEFUN ("ftruncate", Fftruncate, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 Truncate a floating point number to an integral float value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 Rounds the value toward zero.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
893 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
894 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 if (d >= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 IN_FLOAT (d = floor (d), "ftruncate", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 IN_FLOAT (d = ceil (d), "ftruncate", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 #endif /* LISP_FLOAT_TYPE (float-rounding functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 #ifdef FLOAT_CATCH_SIGILL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 static SIGTYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 float_error (int signo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 if (! in_float)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 fatal_error_signal (signo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 EMACS_REESTABLISH_SIGNAL (signo, arith_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 EMACS_UNBLOCK_SIGNAL (signo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 in_float = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 /* Was Fsignal(), but it just doesn't make sense for an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 occurring inside a signal handler to be restartable, considering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 that anything could happen when the error is signaled and trapped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 and considering the asynchronous nature of signal handlers. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 signal_error (Qarith_error, list1 (float_error_arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 /* Another idea was to replace the library function `infnan'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 where SIGILL is signaled. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 #endif /* FLOAT_CATCH_SIGILL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
932 #if defined (HAVE_MATHERR) && !defined(__cplusplus)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
933 int
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 matherr (struct exception *x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 Lisp_Object args;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 if (! in_float)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 /* Not called from emacs-lisp float routines; do the default thing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 /* if (!strcmp (x->name, "pow")) x->name = "expt"; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 args = Fcons (build_string (x->name),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 Fcons (make_float (x->arg1),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ((in_float == 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ? Fcons (make_float (x->arg2), Qnil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 : Qnil)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 switch (x->type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 case DOMAIN: Fsignal (Qdomain_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 case SING: Fsignal (Qsingularity_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 case OVERFLOW: Fsignal (Qoverflow_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 case UNDERFLOW: Fsignal (Qunderflow_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 default: Fsignal (Qarith_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
956 return 1; /* don't set errno or print a message */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 #endif /* HAVE_MATHERR */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 init_floatfns_very_early (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 # ifdef FLOAT_CATCH_SIGILL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 signal (SIGILL, float_error);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
968 # endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 in_float = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 syms_of_floatfns (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
976
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 /* Trig functions. */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
978
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
980 DEFSUBR (Facos);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
981 DEFSUBR (Fasin);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
982 DEFSUBR (Fatan);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
983 DEFSUBR (Fcos);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
984 DEFSUBR (Fsin);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
985 DEFSUBR (Ftan);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 /* Bessel functions */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 104
diff changeset
989
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 #if 0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
991 DEFSUBR (Fbessel_y0);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
992 DEFSUBR (Fbessel_y1);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
993 DEFSUBR (Fbessel_yn);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
994 DEFSUBR (Fbessel_j0);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
995 DEFSUBR (Fbessel_j1);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
996 DEFSUBR (Fbessel_jn);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 /* Error functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 #if 0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1002 DEFSUBR (Ferf);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1003 DEFSUBR (Ferfc);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1004 DEFSUBR (Flog_gamma);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 /* Root and Log functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1010 DEFSUBR (Fexp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 #endif /* LISP_FLOAT_TYPE */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1012 DEFSUBR (Fexpt);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1014 DEFSUBR (Flog);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1015 DEFSUBR (Flog10);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1016 DEFSUBR (Fsqrt);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1017 DEFSUBR (Fcube_root);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 /* Inverse trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1023 DEFSUBR (Facosh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1024 DEFSUBR (Fasinh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1025 DEFSUBR (Fatanh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1026 DEFSUBR (Fcosh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1027 DEFSUBR (Fsinh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1028 DEFSUBR (Ftanh);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 /* Rounding functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1033 DEFSUBR (Fabs);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1035 DEFSUBR (Ffloat);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1036 DEFSUBR (Flogb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 #endif /* LISP_FLOAT_TYPE */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1038 DEFSUBR (Fceiling);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1039 DEFSUBR (Ffloor);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1040 DEFSUBR (Fround);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1041 DEFSUBR (Ftruncate);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 /* Float-rounding functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1046 DEFSUBR (Ffceiling);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1047 DEFSUBR (Fffloor);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1048 DEFSUBR (Ffround);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1049 DEFSUBR (Fftruncate);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 vars_of_floatfns (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 Fprovide (intern ("lisp-float-type"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 }