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