annotate src/floatfns.c @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents 859a2309aef8
children 4be1180a9e89
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 /* Convert float to Lisp_Int if it fits, else signal a range error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 using the given arguments. */
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 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 case 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 static Lisp_Object mark_float (Lisp_Object, void (*) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 extern void print_float (Lisp_Object, Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 static int float_equal (Lisp_Object o1, Lisp_Object o2, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 static unsigned long float_hash (Lisp_Object obj, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("float", float,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 mark_float, print_float, 0, float_equal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 float_hash, struct Lisp_Float);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 mark_float (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 return (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 float_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 return (extract_float (o1) == extract_float (o2));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 float_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 /* mod the value down to 32-bit range */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 /* #### change for 64-bit machines */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 return (unsigned long) fmod (extract_float (obj), 4e9);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 /* Extract a Lisp number as a `double', or signal an error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 double
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 extract_float (Lisp_Object 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 CHECK_INT_OR_FLOAT (num);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 if (FLOATP (num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 return (float_data (XFLOAT (num)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 return (double) XINT (num);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 /* Trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
209 DEFUN ("acos", Facos, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Return the inverse cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
211 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
212 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 if (d > 1.0 || d < -1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 domain_error ("acos", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 IN_FLOAT (d = acos (d), "acos", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
223 DEFUN ("asin", Fasin, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 Return the inverse sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
225 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
226 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 if (d > 1.0 || d < -1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 domain_error ("asin", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 IN_FLOAT (d = asin (d), "asin", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
237 DEFUN ("atan", Fatan, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 Return the inverse tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
239 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
240 (arg1, arg2))
0
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 d = extract_float (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 if (NILP (arg2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 IN_FLOAT (d = atan (d), "atan", arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 double d2 = extract_float (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (d == 0.0 && d2 == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 domain_error2 ("atan", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 IN_FLOAT2 (d = atan2 (d, d2), "atan", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
258 DEFUN ("cos", Fcos, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Return the cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
260 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
261 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 IN_FLOAT (d = cos (d), "cos", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
268 DEFUN ("sin", Fsin, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Return the sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
270 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
271 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 IN_FLOAT (d = sin (d), "sin", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
278 DEFUN ("tan", Ftan, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 Return the tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
280 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
281 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 double c = cos (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 if (c == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 domain_error ("tan", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 IN_FLOAT (d = (sin (d) / c), "tan", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 #endif /* LISP_FLOAT_TYPE (trig functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 /* Bessel functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 #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
297 /* #ifdef LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
299 DEFUN ("bessel-j0", Fbessel_j0, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Return the bessel function j0 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
301 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
302 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 IN_FLOAT (d = j0 (d), "bessel-j0", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
309 DEFUN ("bessel-j1", Fbessel_j1, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 Return the bessel function j1 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
311 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
312 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 IN_FLOAT (d = j1 (d), "bessel-j1", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
319 DEFUN ("bessel-jn", Fbessel_jn, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 Return the order N bessel function output jn of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 The first arg (the order) is truncated to an integer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
322 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
323 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 int i1 = extract_float (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 double f2 = extract_float (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 return make_float (f2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
332 DEFUN ("bessel-y0", Fbessel_y0, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 Return the bessel function y0 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
334 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
335 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 IN_FLOAT (d = y0 (d), "bessel-y0", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
342 DEFUN ("bessel-y1", Fbessel_y1, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 Return the bessel function y1 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
344 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
345 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 IN_FLOAT (d = y1 (d), "bessel-y0", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
352 DEFUN ("bessel-yn", Fbessel_yn, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 Return the order N bessel function output yn of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 The first arg (the order) is truncated to an integer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
355 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
356 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 int i1 = extract_float (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 double f2 = extract_float (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 return make_float (f2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 #endif /* 0 (bessel functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 /* Error functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 #if 0 /* Leave these out unless we see they are worth having. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 /* #ifdef LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
371 DEFUN ("erf", Ferf, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Return the mathematical error function of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
373 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
374 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 IN_FLOAT (d = erf (d), "erf", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
381 DEFUN ("erfc", Ferfc, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 Return the complementary error function of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
383 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
384 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 IN_FLOAT (d = erfc (d), "erfc", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
391 DEFUN ("log-gamma", Flog_gamma, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 Return the log gamma of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
393 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
394 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 IN_FLOAT (d = lgamma (d), "log-gamma", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 #endif /* 0 (error functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 /* Root and Log functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
407 DEFUN ("exp", Fexp, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 Return the exponential base e of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
409 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
410 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 if (d > 709.7827) /* Assume IEEE doubles here */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 range_error ("exp", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 else if (d < -709.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 return make_float (0.0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 IN_FLOAT (d = exp (d), "exp", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
426 DEFUN ("expt", Fexpt, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Return the exponential ARG1 ** ARG2.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
428 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
429 (arg1, arg2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 double f1, f2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 CHECK_INT_OR_FLOAT (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 CHECK_INT_OR_FLOAT (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 if ((INTP (arg1)) && /* common lisp spec */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (INTP (arg2))) /* don't promote, if both are ints */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 EMACS_INT acc, x, y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 x = XINT (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 y = XINT (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 if (y < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 if (x == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 acc = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 else if (x == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 acc = (y & 1) ? -1 : 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 acc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 acc = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 while (y > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 if (y & 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 acc *= x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 x *= x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 y = (unsigned EMACS_INT) y >> 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 return (make_int (acc));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 f1 = (FLOATP (arg1)) ? float_data (XFLOAT (arg1)) : XINT (arg1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 f2 = (FLOATP (arg2)) ? float_data (XFLOAT (arg2)) : XINT (arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 /* Really should check for overflow, too */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 if (f1 == 0.0 && f2 == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 f1 = 1.0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 # ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor(f2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 domain_error2 ("expt", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 # endif /* FLOAT_CHECK_DOMAIN */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 IN_FLOAT2 (f1 = pow (f1, f2), "expt", arg1, arg2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 return make_float (f1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 #else /* !LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
482 DEFUN ("log", Flog, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 Return the natural logarithm of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 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
485 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
486 (arg, base))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 if (d <= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 domain_error2 ("log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 if (NILP (base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 IN_FLOAT (d = log (d), "log", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 double b = extract_float (base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 if (b <= 0.0 || b == 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 domain_error2 ("log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 if (b == 10.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 IN_FLOAT2 (d = log10 (d), "log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 IN_FLOAT2 (d = (log (d) / log (b)), "log", arg, base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
511 DEFUN ("log10", Flog10, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 Return the logarithm base 10 of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
513 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
514 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 if (d <= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 domain_error ("log10", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 IN_FLOAT (d = log10 (d), "log10", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
526 DEFUN ("sqrt", Fsqrt, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 Return the square root of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
528 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
529 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 if (d < 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 domain_error ("sqrt", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 IN_FLOAT (d = sqrt (d), "sqrt", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
541 DEFUN ("cube-root", Fcube_root, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 Return the cube root of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
543 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
544 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 #ifdef HAVE_CBRT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 IN_FLOAT (d = cbrt (d), "cube-root", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 if (d >= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 IN_FLOAT (d = pow (d, 1.0/3.0), "cube-root", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 IN_FLOAT (d = -pow (-d, 1.0/3.0), "cube-root", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 /* Inverse trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 /* #if 0 Not clearly worth adding... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
564 DEFUN ("acosh", Facosh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Return the inverse hyperbolic cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
566 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
567 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 if (d < 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 domain_error ("acosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 #ifdef HAVE_INVERSE_HYPERBOLIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 IN_FLOAT (d = acosh (d), "acosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 IN_FLOAT (d = log (d + sqrt (d*d - 1.0)), "acosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
582 DEFUN ("asinh", Fasinh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 Return the inverse hyperbolic sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
584 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
585 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 #ifdef HAVE_INVERSE_HYPERBOLIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 IN_FLOAT (d = asinh (d), "asinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 IN_FLOAT (d = log (d + sqrt (d*d + 1.0)), "asinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
596 DEFUN ("atanh", Fatanh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 Return the inverse hyperbolic tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
598 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
599 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 if (d >= 1.0 || d <= -1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 domain_error ("atanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 #ifdef HAVE_INVERSE_HYPERBOLIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 IN_FLOAT (d = atanh (d), "atanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 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
610 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
614 DEFUN ("cosh", Fcosh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 Return the hyperbolic cosine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
616 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
617 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 if (d > 710.0 || d < -710.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 range_error ("cosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 IN_FLOAT (d = cosh (d), "cosh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
628 DEFUN ("sinh", Fsinh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 Return the hyperbolic sine of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
630 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
631 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 #ifdef FLOAT_CHECK_DOMAIN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 if (d > 710.0 || d < -710.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 range_error ("sinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 IN_FLOAT (d = sinh (d), "sinh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
642 DEFUN ("tanh", Ftanh, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 Return the hyperbolic tangent of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
644 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
645 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 IN_FLOAT (d = tanh (d), "tanh", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 #endif /* LISP_FLOAT_TYPE (inverse trig functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 /* Rounding functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
655 DEFUN ("abs", Fabs, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 Return the absolute value of ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
657 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
658 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 IN_FLOAT (arg = make_float ((double) fabs (float_data (XFLOAT (arg)))),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 "abs", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 return (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 if (XINT (arg) < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 return (make_int (- XINT (arg)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 return (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
678 DEFUN ("float", Ffloat, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 Return the floating point number equal to ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
680 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
681 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 if (INTP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 return make_float ((double) XINT (arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 else /* give 'em the same float back */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
694 DEFUN ("logb", Flogb, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 Return largest integer <= the base 2 log of the magnitude of ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 This is the same as the exponent of a float.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
697 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
698 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 double f = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 if (f == 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 return (make_int (- (((EMACS_UINT) 1) << (VALBITS - 1)))); /* most-negative-fixnum */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 #ifdef HAVE_LOGB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 IN_FLOAT (val = make_int (logb (f)), "logb", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 return (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 #ifdef HAVE_FREXP
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 exqp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 IN_FLOAT (frexp (f, &exqp), "logb", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 return (make_int (exqp - 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 EMACS_INT val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 if (f < 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 f = -f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 val = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 while (f < 0.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 for (i = 1, d = 0.5; d * d >= f; i += i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 d *= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 f /= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 val -= i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 while (f >= 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 for (i = 1, d = 2.0; d * d <= f; i += i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 d *= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 f /= d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 val += i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 return (make_int (val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 #endif /* ! HAVE_FREXP */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 #endif /* ! HAVE_LOGB */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
747 DEFUN ("ceiling", Fceiling, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 Return the smallest integer no less than ARG. (Round toward +inf.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
749 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
750 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 IN_FLOAT ((d = ceil (float_data (XFLOAT (arg)))), "ceiling", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 return (float_to_int (d, "ceiling", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
767 DEFUN ("floor", Ffloor, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 Return the largest integer no greater than ARG. (Round towards -inf.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 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
770 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
771 (arg, divisor))
0
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 (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 if (! NILP (divisor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 EMACS_INT i1, i2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 CHECK_INT_OR_FLOAT (divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 if (FLOATP (arg) || FLOATP (divisor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 double f1, f2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 f1 = ((FLOATP (arg)) ? float_data (XFLOAT (arg)) : XINT (arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 f2 = ((FLOATP (divisor)) ? float_data (XFLOAT (divisor)) : XINT (divisor));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 if (f2 == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 Fsignal (Qarith_error, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 IN_FLOAT2 (f1 = floor (f1 / f2), "floor", arg, divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 return float_to_int (f1, "floor", arg, divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 i1 = XINT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 i2 = XINT (divisor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 if (i2 == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 Fsignal (Qarith_error, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 /* With C's /, the result is implementation-defined if either operand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 is negative, so use only nonnegative operands. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 i1 = (i2 < 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ? (i1 <= 0 ? -i1 / -i2 : -1 - ((i1 - 1) / -i2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 : (i1 < 0 ? -1 - ((-1 - i1) / i2) : i1 / i2));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 return (make_int (i1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 IN_FLOAT ((d = floor (float_data (XFLOAT (arg)))), "floor", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 return (float_to_int (d, "floor", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
823 DEFUN ("round", Fround, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 Return the nearest integer to ARG.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
825 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
826 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 double d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 /* Screw the prevailing rounding mode. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 IN_FLOAT ((d = rint (float_data (XFLOAT (arg)))), "round", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 return (float_to_int (d, "round", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
843 DEFUN ("truncate", Ftruncate, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 Truncate a floating point number to an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 Rounds the value toward zero.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
846 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
847 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 CHECK_INT_OR_FLOAT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 if (FLOATP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 return (float_to_int (float_data (XFLOAT (arg)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 "truncate", arg, Qunbound));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 /* Float-rounding functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 /* #if 1 It's not clear these are worth adding... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
864 DEFUN ("fceiling", Ffceiling, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 Return the smallest integer no less than ARG, as a float.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 \(Round toward +inf.\)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
867 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
868 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 IN_FLOAT (d = ceil (d), "fceiling", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
875 DEFUN ("ffloor", Fffloor, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 Return the largest integer no greater than ARG, as a float.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 \(Round towards -inf.\)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
878 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
879 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 IN_FLOAT (d = floor (d), "ffloor", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
886 DEFUN ("fround", Ffround, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 Return the nearest integer to ARG, as a float.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
888 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
889 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 IN_FLOAT (d = rint (d), "fround", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
896 DEFUN ("ftruncate", Fftruncate, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 Truncate a floating point number to an integral float value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 Rounds the value toward zero.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
899 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
900 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 double d = extract_float (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 if (d >= 0.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 IN_FLOAT (d = floor (d), "ftruncate", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 IN_FLOAT (d = ceil (d), "ftruncate", arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 return make_float (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 #endif /* LISP_FLOAT_TYPE (float-rounding functions) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 #ifdef FLOAT_CATCH_SIGILL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 static SIGTYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 float_error (int 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 if (! in_float)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 fatal_error_signal (signo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 EMACS_REESTABLISH_SIGNAL (signo, arith_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 EMACS_UNBLOCK_SIGNAL (signo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 in_float = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 /* Was Fsignal(), but it just doesn't make sense for an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 occurring inside a signal handler to be restartable, considering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 that anything could happen when the error is signaled and trapped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 and considering the asynchronous nature of signal handlers. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 signal_error (Qarith_error, list1 (float_error_arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 /* Another idea was to replace the library function `infnan'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 where SIGILL is signaled. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 #endif /* FLOAT_CATCH_SIGILL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 #ifdef HAVE_MATHERR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 matherr (struct exception *x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 Lisp_Object args;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 if (! in_float)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 /* Not called from emacs-lisp float routines; do the default thing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 /* if (!strcmp (x->name, "pow")) x->name = "expt"; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 args = Fcons (build_string (x->name),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 Fcons (make_float (x->arg1),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ((in_float == 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ? Fcons (make_float (x->arg2), Qnil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 : Qnil)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 switch (x->type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 case DOMAIN: Fsignal (Qdomain_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 case SING: Fsignal (Qsingularity_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 case OVERFLOW: Fsignal (Qoverflow_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 case UNDERFLOW: Fsignal (Qunderflow_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 default: Fsignal (Qarith_error, args); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 return (1); /* don't set errno or print a message */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 #endif /* HAVE_MATHERR */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 init_floatfns_very_early (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 # ifdef FLOAT_CATCH_SIGILL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 signal (SIGILL, float_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 # endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 in_float = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 syms_of_floatfns (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 /* Trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
986 DEFSUBR (Facos);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
987 DEFSUBR (Fasin);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
988 DEFSUBR (Fatan);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
989 DEFSUBR (Fcos);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
990 DEFSUBR (Fsin);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
991 DEFSUBR (Ftan);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 /* Bessel functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 #if 0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
997 DEFSUBR (Fbessel_y0);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
998 DEFSUBR (Fbessel_y1);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
999 DEFSUBR (Fbessel_yn);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1000 DEFSUBR (Fbessel_j0);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1001 DEFSUBR (Fbessel_j1);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1002 DEFSUBR (Fbessel_jn);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 /* Error functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 #if 0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1008 DEFSUBR (Ferf);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1009 DEFSUBR (Ferfc);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1010 DEFSUBR (Flog_gamma);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 /* Root and Log functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1016 DEFSUBR (Fexp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 #endif /* LISP_FLOAT_TYPE */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1018 DEFSUBR (Fexpt);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1020 DEFSUBR (Flog);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1021 DEFSUBR (Flog10);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1022 DEFSUBR (Fsqrt);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1023 DEFSUBR (Fcube_root);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 /* Inverse trig functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1029 DEFSUBR (Facosh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1030 DEFSUBR (Fasinh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1031 DEFSUBR (Fatanh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1032 DEFSUBR (Fcosh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1033 DEFSUBR (Fsinh);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1034 DEFSUBR (Ftanh);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 /* Rounding functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1039 DEFSUBR (Fabs);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1041 DEFSUBR (Ffloat);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1042 DEFSUBR (Flogb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 #endif /* LISP_FLOAT_TYPE */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1044 DEFSUBR (Fceiling);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1045 DEFSUBR (Ffloor);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1046 DEFSUBR (Fround);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1047 DEFSUBR (Ftruncate);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 /* Float-rounding functions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 #ifdef LISP_FLOAT_TYPE
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1052 DEFSUBR (Ffceiling);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1053 DEFSUBR (Fffloor);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1054 DEFSUBR (Ffround);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
1055 DEFSUBR (Fftruncate);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 vars_of_floatfns (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 Fprovide (intern ("lisp-float-type"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 }