Mercurial > emacs
annotate src/floatfns.c @ 35401:c00e94a506a2
(tooltip-hide-delay): New user-option.
(tooltip-show): Use tooltip-hide-delay instead of the default.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 18 Jan 2001 14:38:45 +0000 |
parents | e19d38e14720 |
children | 911382113c16 |
rev | line source |
---|---|
102 | 1 /* Primitive operations on floating point for GNU Emacs Lisp interpreter. |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25645
diff
changeset
|
2 Copyright (C) 1988, 1993, 1994, 1999 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 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14076
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14076
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
102 | 20 |
21 | |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
22 /* 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
|
23 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
|
24 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
|
25 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
26 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
|
27 Define HAVE_CBRT if you have cbrt. |
19737
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
28 Define HAVE_RINT if you have a working rint. |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
29 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
|
30 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
31 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
|
32 (This should happen automatically.) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
33 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
34 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
|
35 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
|
36 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
37 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
|
38 (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
|
39 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
40 Define FLOAT_CHECK_DOMAIN if the float library doesn't handle errors by |
14036 | 41 either setting errno, or signaling SIGFPE/SIGILL. Otherwise, domain and |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
42 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
|
43 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
|
44 a domain error occurs.) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
45 */ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
46 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25645
diff
changeset
|
47 #include <config.h> |
102 | 48 #include <signal.h> |
49 #include "lisp.h" | |
638 | 50 #include "syssignal.h" |
102 | 51 |
20122
923e1f635ace
No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents:
19737
diff
changeset
|
52 #if STDC_HEADERS |
923e1f635ace
No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents:
19737
diff
changeset
|
53 #include <float.h> |
923e1f635ace
No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents:
19737
diff
changeset
|
54 #endif |
923e1f635ace
No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents:
19737
diff
changeset
|
55 |
16786
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
56 /* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
57 #ifndef IEEE_FLOATING_POINT |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
58 #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
59 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
60 #define IEEE_FLOATING_POINT 1 |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
61 #else |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
62 #define IEEE_FLOATING_POINT 0 |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
63 #endif |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
64 #endif |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
65 |
4843
136e32c763e3
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
66 /* 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
|
67 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
|
68 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
|
69 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
|
70 These macros prevent the name conflict. */ |
136e32c763e3
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
71 #if defined (HPUX) && !defined (HPUX8) |
136e32c763e3
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
72 #define _MAXLDBL floatfns_maxldbl |
136e32c763e3
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
73 #define _NMAXLDBL floatfns_nmaxldbl |
136e32c763e3
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
74 #endif |
136e32c763e3
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
75 |
102 | 76 #include <math.h> |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
77 |
4881
e53d4ae93675
Declare `logb' only if HAVE_LOGB is defined.
Brian Fox <bfox@gnu.org>
parents:
4843
diff
changeset
|
78 /* 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
|
79 #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
|
80 extern double logb (); |
7448
bf93ac2d8409
Don't declare logb if it is a macro.
Richard M. Stallman <rms@gnu.org>
parents:
7361
diff
changeset
|
81 #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
|
82 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
83 #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
|
84 /* 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
|
85 # ifndef HAVE_MATHERR |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
86 # define HAVE_MATHERR |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
87 # endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
88 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
89 |
3027
7ed290bef028
Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3025
diff
changeset
|
90 #ifdef NO_MATHERR |
3025
d09f68ccd145
[NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
91 #undef HAVE_MATHERR |
d09f68ccd145
[NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
92 #endif |
d09f68ccd145
[NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
93 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
94 #ifdef HAVE_MATHERR |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
95 # ifdef FLOAT_CHECK_ERRNO |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
96 # undef FLOAT_CHECK_ERRNO |
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 # ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
99 # undef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
100 # endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
101 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
102 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
103 #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
|
104 #define FLOAT_CHECK_ERRNO |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
105 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
106 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
107 #ifdef FLOAT_CHECK_ERRNO |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
108 # include <errno.h> |
485 | 109 |
31095
e19d38e14720
[USE_CRT_DLL]: Remove unnecessary extern, which screws
Andrew Innes <andrewi@gnu.org>
parents:
27727
diff
changeset
|
110 #ifndef USE_CRT_DLL |
485 | 111 extern int errno; |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
112 #endif |
31095
e19d38e14720
[USE_CRT_DLL]: Remove unnecessary extern, which screws
Andrew Innes <andrewi@gnu.org>
parents:
27727
diff
changeset
|
113 #endif |
485 | 114 |
115 /* Avoid traps on VMS from sinh and cosh. | |
116 All the other functions set errno instead. */ | |
117 | |
118 #ifdef VMS | |
119 #undef cosh | |
120 #undef sinh | |
121 #define cosh(x) ((exp(x)+exp(-x))*0.5) | |
122 #define sinh(x) ((exp(x)-exp(-x))*0.5) | |
123 #endif /* VMS */ | |
124 | |
621 | 125 static SIGTYPE float_error (); |
102 | 126 |
127 /* Nonzero while executing in floating point. | |
128 This tells float_error what to do. */ | |
129 | |
130 static int in_float; | |
131 | |
132 /* If an argument is out of range for a mathematical function, | |
16207 | 133 here is the actual argument value to use in the error message. |
134 These variables are used only across the floating point library call | |
135 so there is no need to staticpro them. */ | |
102 | 136 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
137 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
|
138 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
139 static char *float_error_fn_name; |
102 | 140 |
485 | 141 /* Evaluate the floating point expression D, recording NUM |
142 as the original argument for error messages. | |
143 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
|
144 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
|
145 |
699ae3079c09
* floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents:
1715
diff
changeset
|
146 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
|
147 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
|
148 check properly. */ |
485 | 149 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
150 #ifdef FLOAT_CHECK_ERRNO |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
151 #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
|
152 do { \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
153 float_error_arg = num; \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
154 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
|
155 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
|
156 switch (errno) { \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
157 case 0: break; \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 } \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
162 } while (0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
163 #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
|
164 do { \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
165 float_error_arg = num; \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
166 float_error_arg2 = num2; \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
167 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
|
168 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
|
169 switch (errno) { \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
170 case 0: break; \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
171 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
|
172 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
|
173 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
|
174 } \ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
175 } while (0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
176 #else |
3407
d00aaf536bfd
[!FLOAT_CHECK_ERRNO] (IN_FLOAT): New definition.
Richard M. Stallman <rms@gnu.org>
parents:
3094
diff
changeset
|
177 #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
|
178 #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
|
179 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
180 |
6375
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
181 /* 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
|
182 using the given arguments. */ |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
183 #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
|
184 do \ |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
185 { \ |
8825
5e5f6d06fb5b
(FLOAT_TO_INT, FLOAT_TO_INT2): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7448
diff
changeset
|
186 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
|
187 (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
|
188 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
|
189 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
|
190 } \ |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
191 while (0) |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
192 #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
|
193 do \ |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
194 { \ |
8825
5e5f6d06fb5b
(FLOAT_TO_INT, FLOAT_TO_INT2): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7448
diff
changeset
|
195 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
|
196 (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
|
197 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
|
198 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
|
199 } \ |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
200 while (0) |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
201 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
202 #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
|
203 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
|
204 #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
|
205 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
|
206 #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
|
207 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
|
208 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
|
209 #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
|
210 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
|
211 #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
|
212 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
|
213 Fcons ((a1), Fcons ((a2), Qnil)))) |
102 | 214 |
215 /* Extract a Lisp number as a `double', or signal an error. */ | |
216 | |
217 double | |
218 extract_float (num) | |
219 Lisp_Object num; | |
220 { | |
221 CHECK_NUMBER_OR_FLOAT (num, 0); | |
222 | |
9129
b2d1d925d5cc
(extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents:
8825
diff
changeset
|
223 if (FLOATP (num)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
224 return XFLOAT_DATA (num); |
102 | 225 return (double) XINT (num); |
226 } | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
227 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
228 /* Trig functions. */ |
102 | 229 |
230 DEFUN ("acos", Facos, Sacos, 1, 1, 0, | |
231 "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
|
232 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
233 register Lisp_Object arg; |
102 | 234 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
235 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
|
236 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
237 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
|
238 domain_error ("acos", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
239 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
240 IN_FLOAT (d = acos (d), "acos", arg); |
102 | 241 return make_float (d); |
242 } | |
243 | |
244 DEFUN ("asin", Fasin, Sasin, 1, 1, 0, | |
245 "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
|
246 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
247 register Lisp_Object arg; |
102 | 248 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
249 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
|
250 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
251 if (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
|
252 domain_error ("asin", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
253 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
254 IN_FLOAT (d = asin (d), "asin", arg); |
102 | 255 return make_float (d); |
256 } | |
257 | |
258 DEFUN ("atan", Fatan, Satan, 1, 1, 0, | |
259 "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
|
260 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
261 register Lisp_Object arg; |
102 | 262 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
263 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
|
264 IN_FLOAT (d = atan (d), "atan", arg); |
102 | 265 return make_float (d); |
266 } | |
267 | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
268 DEFUN ("cos", Fcos, Scos, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
269 "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
|
270 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
271 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
272 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
273 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
|
274 IN_FLOAT (d = cos (d), "cos", arg); |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
275 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
276 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
277 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
278 DEFUN ("sin", Fsin, Ssin, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
279 "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
|
280 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
281 register Lisp_Object arg; |
102 | 282 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
283 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
|
284 IN_FLOAT (d = sin (d), "sin", arg); |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
285 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
286 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
287 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
288 DEFUN ("tan", Ftan, Stan, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
289 "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
|
290 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
291 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
292 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
293 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
|
294 double c = cos (d); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
295 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
296 if (c == 0.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
297 domain_error ("tan", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
298 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
299 IN_FLOAT (d = sin (d) / c, "tan", arg); |
102 | 300 return make_float (d); |
301 } | |
302 | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
303 #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
|
304 |
102 | 305 DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, |
306 "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
|
307 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
308 register Lisp_Object arg; |
102 | 309 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
310 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
|
311 IN_FLOAT (d = j0 (d), "bessel-j0", arg); |
102 | 312 return make_float (d); |
313 } | |
314 | |
315 DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0, | |
316 "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
|
317 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
318 register Lisp_Object arg; |
102 | 319 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
320 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
|
321 IN_FLOAT (d = j1 (d), "bessel-j1", arg); |
102 | 322 return make_float (d); |
323 } | |
324 | |
325 DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0, | |
326 "Return the order N bessel function output jn of ARG.\n\ | |
327 The first arg (the order) is truncated to an integer.") | |
14076
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
328 (n, arg) |
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
329 register Lisp_Object n, arg; |
102 | 330 { |
14076
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
331 int i1 = extract_float (n); |
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
332 double f2 = extract_float (arg); |
102 | 333 |
14076
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
334 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", n); |
102 | 335 return make_float (f2); |
336 } | |
337 | |
338 DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0, | |
339 "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
|
340 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
341 register Lisp_Object arg; |
102 | 342 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
343 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
|
344 IN_FLOAT (d = y0 (d), "bessel-y0", arg); |
102 | 345 return make_float (d); |
346 } | |
347 | |
348 DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0, | |
349 "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
|
350 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
351 register Lisp_Object arg; |
102 | 352 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
353 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
|
354 IN_FLOAT (d = y1 (d), "bessel-y0", arg); |
102 | 355 return make_float (d); |
356 } | |
357 | |
358 DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0, | |
359 "Return the order N bessel function output yn of ARG.\n\ | |
360 The first arg (the order) is truncated to an integer.") | |
14076
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
361 (n, arg) |
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
362 register Lisp_Object n, arg; |
102 | 363 { |
14076
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
364 int i1 = extract_float (n); |
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
365 double f2 = extract_float (arg); |
102 | 366 |
14076
b339e9aaea4b
(Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
367 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", n); |
102 | 368 return make_float (f2); |
369 } | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
370 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
371 #endif |
102 | 372 |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
373 #if 0 /* Leave these out unless we see they are worth having. */ |
102 | 374 |
375 DEFUN ("erf", Ferf, Serf, 1, 1, 0, | |
376 "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
|
377 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
378 register Lisp_Object arg; |
102 | 379 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
380 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
|
381 IN_FLOAT (d = erf (d), "erf", arg); |
102 | 382 return make_float (d); |
383 } | |
384 | |
385 DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, | |
386 "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
|
387 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
388 register Lisp_Object arg; |
102 | 389 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
390 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
|
391 IN_FLOAT (d = erfc (d), "erfc", arg); |
102 | 392 return make_float (d); |
393 } | |
394 | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
395 DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
396 "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
|
397 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
398 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
399 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
400 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
|
401 IN_FLOAT (d = lgamma (d), "log-gamma", arg); |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
402 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
403 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
404 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
405 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
|
406 "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
|
407 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
408 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
409 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
410 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
|
411 #ifdef HAVE_CBRT |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
412 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
|
413 #else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
414 if (d >= 0.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
415 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
|
416 else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
417 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
|
418 #endif |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
419 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
420 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
421 |
694 | 422 #endif |
423 | |
102 | 424 DEFUN ("exp", Fexp, Sexp, 1, 1, 0, |
425 "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
|
426 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
427 register Lisp_Object arg; |
102 | 428 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
429 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
|
430 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
431 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
|
432 range_error ("exp", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
433 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
|
434 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
|
435 else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
436 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
437 IN_FLOAT (d = exp (d), "exp", arg); |
102 | 438 return make_float (d); |
439 } | |
440 | |
441 DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, | |
13442 | 442 "Return the exponential ARG1 ** ARG2.") |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
443 (arg1, arg2) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
444 register Lisp_Object arg1, arg2; |
102 | 445 { |
446 double f1, f2; | |
447 | |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 && INTEGERP (arg2)) /* don't promote, if both are ints */ |
102 | 452 { /* this can be improved by pre-calculating */ |
12537
476296adb950
(Fexpt): Use EMACS_INT for integer calculation.
Karl Heuer <kwzh@gnu.org>
parents:
11859
diff
changeset
|
453 EMACS_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
|
454 Lisp_Object val; |
8ab0a7453577
(Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
455 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
456 x = XINT (arg1); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
457 y = XINT (arg2); |
102 | 458 acc = 1; |
459 | |
460 if (y < 0) | |
461 { | |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
462 if (x == 1) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
463 acc = 1; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
464 else if (x == -1) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
465 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
|
466 else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
467 acc = 0; |
102 | 468 } |
469 else | |
470 { | |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
471 while (y > 0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
472 { |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
473 if (y & 1) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
474 acc *= x; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
475 x *= x; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
476 y = (unsigned)y >> 1; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
477 } |
102 | 478 } |
9267
1b685d477c10
(FLOAT_TO_INT, FLOAT_TO_INT2, Fexpt, Flogb, Ffloor): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents:
9129
diff
changeset
|
479 XSETINT (val, acc); |
3673
8ab0a7453577
(Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
480 return val; |
102 | 481 } |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
482 f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1); |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
483 f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2); |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
484 /* 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
|
485 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
|
486 f1 = 1.0; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
487 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
488 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
|
489 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
|
490 #endif |
4529 | 491 IN_FLOAT2 (f1 = pow (f1, f2), "expt", arg1, arg2); |
102 | 492 return make_float (f1); |
493 } | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
494 |
1005
70ed307d9047
* floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents:
694
diff
changeset
|
495 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
|
496 "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
|
497 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
|
498 (arg, base) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
499 register Lisp_Object arg, base; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
500 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
501 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
|
502 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
503 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
504 if (d <= 0.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
505 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
|
506 #endif |
1005
70ed307d9047
* floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents:
694
diff
changeset
|
507 if (NILP (base)) |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
508 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
|
509 else |
70ed307d9047
* floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents:
694
diff
changeset
|
510 { |
70ed307d9047
* floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents:
694
diff
changeset
|
511 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
|
512 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
513 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
514 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
|
515 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
|
516 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
517 if (b == 10.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
518 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
|
519 else |
3407
d00aaf536bfd
[!FLOAT_CHECK_ERRNO] (IN_FLOAT): New definition.
Richard M. Stallman <rms@gnu.org>
parents:
3094
diff
changeset
|
520 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
|
521 } |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
522 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
523 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
524 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
525 DEFUN ("log10", Flog10, Slog10, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
526 "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
|
527 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
528 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
529 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
530 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
|
531 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
532 if (d <= 0.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
533 domain_error ("log10", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
534 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
535 IN_FLOAT (d = log10 (d), "log10", arg); |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
536 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
537 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
538 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
539 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
540 "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
|
541 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
542 register Lisp_Object arg; |
102 | 543 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
544 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
|
545 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
546 if (d < 0.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
547 domain_error ("sqrt", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
548 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
549 IN_FLOAT (d = sqrt (d), "sqrt", arg); |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
550 return make_float (d); |
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 |
694 | 553 #if 0 /* Not clearly worth adding. */ |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
554 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
555 DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
556 "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
|
557 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
558 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
559 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
560 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
|
561 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
562 if (d < 1.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
563 domain_error ("acosh", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
564 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
565 #ifdef HAVE_INVERSE_HYPERBOLIC |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
566 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
|
567 #else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
568 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
|
569 #endif |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
570 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
571 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
572 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
573 DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
574 "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
|
575 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
576 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
577 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
578 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
|
579 #ifdef HAVE_INVERSE_HYPERBOLIC |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
580 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
|
581 #else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
582 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
|
583 #endif |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
584 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
585 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
586 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
587 DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
588 "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
|
589 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
590 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
591 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
592 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
|
593 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
594 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
|
595 domain_error ("atanh", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
596 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
597 #ifdef HAVE_INVERSE_HYPERBOLIC |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
598 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
|
599 #else |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
600 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
|
601 #endif |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
602 return make_float (d); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
603 } |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
604 |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
605 DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
606 "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
|
607 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
608 register Lisp_Object arg; |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
609 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
610 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
|
611 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
612 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
|
613 range_error ("cosh", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
614 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
615 IN_FLOAT (d = cosh (d), "cosh", arg); |
102 | 616 return make_float (d); |
617 } | |
618 | |
619 DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, | |
620 "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
|
621 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
622 register Lisp_Object arg; |
102 | 623 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
624 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
|
625 #ifdef FLOAT_CHECK_DOMAIN |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
626 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
|
627 range_error ("sinh", arg); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
628 #endif |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
629 IN_FLOAT (d = sinh (d), "sinh", arg); |
102 | 630 return make_float (d); |
631 } | |
632 | |
633 DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, | |
634 "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
|
635 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
636 register Lisp_Object arg; |
102 | 637 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
638 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
|
639 IN_FLOAT (d = tanh (d), "tanh", arg); |
102 | 640 return make_float (d); |
641 } | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
642 #endif |
102 | 643 |
644 DEFUN ("abs", Fabs, Sabs, 1, 1, 0, | |
645 "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
|
646 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
647 register Lisp_Object arg; |
102 | 648 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
649 CHECK_NUMBER_OR_FLOAT (arg, 0); |
102 | 650 |
9129
b2d1d925d5cc
(extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents:
8825
diff
changeset
|
651 if (FLOATP (arg)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
652 IN_FLOAT (arg = make_float (fabs (XFLOAT_DATA (arg))), "abs", arg); |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
653 else if (XINT (arg) < 0) |
9365
0b431684f97b
(Fabs): Don't use XFASTINT when negative.
Karl Heuer <kwzh@gnu.org>
parents:
9267
diff
changeset
|
654 XSETINT (arg, - XINT (arg)); |
102 | 655 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
656 return arg; |
102 | 657 } |
658 | |
659 DEFUN ("float", Ffloat, Sfloat, 1, 1, 0, | |
660 "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
|
661 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
662 register Lisp_Object arg; |
102 | 663 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
664 CHECK_NUMBER_OR_FLOAT (arg, 0); |
102 | 665 |
9129
b2d1d925d5cc
(extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents:
8825
diff
changeset
|
666 if (INTEGERP (arg)) |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
667 return make_float ((double) XINT (arg)); |
102 | 668 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
|
669 return arg; |
102 | 670 } |
671 | |
672 DEFUN ("logb", Flogb, Slogb, 1, 1, 0, | |
4590 | 673 "Returns largest integer <= the base 2 log of the magnitude of ARG.\n\ |
102 | 674 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
|
675 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
676 Lisp_Object arg; |
102 | 677 { |
2119
4077ef8ad483
* floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents:
2094
diff
changeset
|
678 Lisp_Object val; |
11265
b2291296ec87
(Flogb): Use EMACS_INT for `value'.
Richard M. Stallman <rms@gnu.org>
parents:
9365
diff
changeset
|
679 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
|
680 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
|
681 |
6359
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
682 if (f == 0.0) |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
683 value = -(VALMASK >> 1); |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
684 else |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
685 { |
4501
9352d7d021c2
* config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents:
3673
diff
changeset
|
686 #ifdef HAVE_LOGB |
6359
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
687 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
|
688 #else |
9352d7d021c2
* config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents:
3673
diff
changeset
|
689 #ifdef HAVE_FREXP |
11859
8d57babf4b36
(Flogb): frexp needs a pointer to int, not EMACS_INT.
Karl Heuer <kwzh@gnu.org>
parents:
11265
diff
changeset
|
690 int ivalue; |
8d57babf4b36
(Flogb): frexp needs a pointer to int, not EMACS_INT.
Karl Heuer <kwzh@gnu.org>
parents:
11265
diff
changeset
|
691 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
|
692 value = ivalue - 1; |
2205
c021f53fe7e5
* floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents:
2129
diff
changeset
|
693 #else |
6359
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
694 int i; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
695 double d; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
696 if (f < 0.0) |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
697 f = -f; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
698 value = -1; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
699 while (f < 0.5) |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
700 { |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
701 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
|
702 d *= d; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
703 f /= d; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
704 value -= i; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
705 } |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
706 while (f >= 1.0) |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
707 { |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
708 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
|
709 d *= d; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
710 f /= d; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
711 value += i; |
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
712 } |
4501
9352d7d021c2
* config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents:
3673
diff
changeset
|
713 #endif |
2205
c021f53fe7e5
* floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents:
2129
diff
changeset
|
714 #endif |
6359
800c035273e9
(Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents:
6314
diff
changeset
|
715 } |
9267
1b685d477c10
(FLOAT_TO_INT, FLOAT_TO_INT2, Fexpt, Flogb, Ffloor): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents:
9129
diff
changeset
|
716 XSETINT (val, value); |
2119
4077ef8ad483
* floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents:
2094
diff
changeset
|
717 return val; |
102 | 718 } |
719 | |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
720 |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
721 /* the rounding functions */ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
722 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
723 static Lisp_Object |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
724 rounding_driver (arg, divisor, double_round, int_round2, name) |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
725 register Lisp_Object arg, divisor; |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
726 double (*double_round) (); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
727 EMACS_INT (*int_round2) (); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
728 char *name; |
102 | 729 { |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
730 CHECK_NUMBER_OR_FLOAT (arg, 0); |
102 | 731 |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
732 if (! NILP (divisor)) |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
733 { |
12537
476296adb950
(Fexpt): Use EMACS_INT for integer calculation.
Karl Heuer <kwzh@gnu.org>
parents:
11859
diff
changeset
|
734 EMACS_INT i1, i2; |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
735 |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
736 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
|
737 |
9129
b2d1d925d5cc
(extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents:
8825
diff
changeset
|
738 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
|
739 { |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
740 double f1, f2; |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
741 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
742 f1 = FLOATP (arg) ? XFLOAT_DATA (arg) : XINT (arg); |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
743 f2 = (FLOATP (divisor) ? XFLOAT_DATA (divisor) : XINT (divisor)); |
16786
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
744 if (! IEEE_FLOATING_POINT && f2 == 0) |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
745 Fsignal (Qarith_error, Qnil); |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
746 |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
747 IN_FLOAT2 (f1 = (*double_round) (f1 / f2), name, arg, divisor); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
748 FLOAT_TO_INT2 (f1, arg, name, arg, divisor); |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
749 return arg; |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
750 } |
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 i1 = XINT (arg); |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
753 i2 = XINT (divisor); |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
754 |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
755 if (i2 == 0) |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
756 Fsignal (Qarith_error, Qnil); |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
757 |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
758 XSETINT (arg, (*int_round2) (i1, i2)); |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
759 return arg; |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
760 } |
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
761 |
9129
b2d1d925d5cc
(extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents:
8825
diff
changeset
|
762 if (FLOATP (arg)) |
6375
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
763 { |
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
764 double d; |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
765 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
766 IN_FLOAT (d = (*double_round) (XFLOAT_DATA (arg)), name, arg); |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
767 FLOAT_TO_INT (d, arg, name, arg); |
6375
212dcd2c06e4
(FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents:
6359
diff
changeset
|
768 } |
102 | 769 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
770 return arg; |
102 | 771 } |
772 | |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
773 /* With C's /, the result is implementation-defined if either operand |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
774 is negative, so take care with negative operands in the following |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
775 integer functions. */ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
776 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
777 static EMACS_INT |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
778 ceiling2 (i1, i2) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
779 EMACS_INT i1, i2; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
780 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
781 return (i2 < 0 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
782 ? (i1 < 0 ? ((-1 - i1) / -i2) + 1 : - (i1 / -i2)) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
783 : (i1 <= 0 ? - (-i1 / i2) : ((i1 - 1) / i2) + 1)); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
784 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
785 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
786 static EMACS_INT |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
787 floor2 (i1, i2) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
788 EMACS_INT i1, i2; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
789 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
790 return (i2 < 0 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
791 ? (i1 <= 0 ? -i1 / -i2 : -1 - ((i1 - 1) / -i2)) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
792 : (i1 < 0 ? -1 - ((-1 - i1) / i2) : i1 / i2)); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
793 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
794 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
795 static EMACS_INT |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
796 truncate2 (i1, i2) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
797 EMACS_INT i1, i2; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
798 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
799 return (i2 < 0 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
800 ? (i1 < 0 ? -i1 / -i2 : - (i1 / -i2)) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
801 : (i1 < 0 ? - (-i1 / i2) : i1 / i2)); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
802 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
803 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
804 static EMACS_INT |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
805 round2 (i1, i2) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
806 EMACS_INT i1, i2; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
807 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
808 /* The C language's division operator gives us one remainder R, but |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
809 we want the remainder R1 on the other side of 0 if R1 is closer |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
810 to 0 than R is; because we want to round to even, we also want R1 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
811 if R and R1 are the same distance from 0 and if C's quotient is |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
812 odd. */ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
813 EMACS_INT q = i1 / i2; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
814 EMACS_INT r = i1 % i2; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
815 EMACS_INT abs_r = r < 0 ? -r : r; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
816 EMACS_INT abs_r1 = (i2 < 0 ? -i2 : i2) - abs_r; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
817 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
818 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
819 |
19737
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
820 /* The code uses emacs_rint, so that it works to undefine HAVE_RINT |
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
821 if `rint' exists but does not work right. */ |
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
822 #ifdef HAVE_RINT |
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
823 #define emacs_rint rint |
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
824 #else |
16929
a6b5ec9a51b4
[!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents:
16857
diff
changeset
|
825 static double |
19737
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
826 emacs_rint (d) |
16929
a6b5ec9a51b4
[!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents:
16857
diff
changeset
|
827 double d; |
a6b5ec9a51b4
[!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents:
16857
diff
changeset
|
828 { |
16956 | 829 return floor (d + 0.5); |
16929
a6b5ec9a51b4
[!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents:
16857
diff
changeset
|
830 } |
a6b5ec9a51b4
[!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents:
16857
diff
changeset
|
831 #endif |
a6b5ec9a51b4
[!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents:
16857
diff
changeset
|
832 |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
833 static double |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
834 double_identity (d) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
835 double d; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
836 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
837 return d; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
838 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
839 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
840 DEFUN ("ceiling", Fceiling, Sceiling, 1, 2, 0, |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
841 "Return the smallest integer no less than ARG. (Round toward +inf.)\n\ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
842 With optional DIVISOR, return the smallest integer no less than ARG/DIVISOR.") |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
843 (arg, divisor) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
844 Lisp_Object arg, divisor; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
845 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
846 return rounding_driver (arg, divisor, ceil, ceiling2, "ceiling"); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
847 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
848 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
849 DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0, |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
850 "Return the largest integer no greater than ARG. (Round towards -inf.)\n\ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
851 With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR.") |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
852 (arg, divisor) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
853 Lisp_Object arg, divisor; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
854 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
855 return rounding_driver (arg, divisor, floor, floor2, "floor"); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
856 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
857 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
858 DEFUN ("round", Fround, Sround, 1, 2, 0, |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
859 "Return the nearest integer to ARG.\n\ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
860 With optional DIVISOR, return the nearest integer to ARG/DIVISOR.") |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
861 (arg, divisor) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
862 Lisp_Object arg, divisor; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
863 { |
19737
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
864 return rounding_driver (arg, divisor, emacs_rint, round2, "round"); |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
865 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
866 |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
867 DEFUN ("truncate", Ftruncate, Struncate, 1, 2, 0, |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
868 "Truncate a floating point number to an int.\n\ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
869 Rounds ARG toward zero.\n\ |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
870 With optional DIVISOR, truncate ARG/DIVISOR.") |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
871 (arg, divisor) |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
872 Lisp_Object arg, divisor; |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
873 { |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
874 return rounding_driver (arg, divisor, double_identity, truncate2, |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
875 "truncate"); |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
876 } |
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
877 |
4506
6131dad14f6f
(Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents:
4501
diff
changeset
|
878 |
16786
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
879 Lisp_Object |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
880 fmod_float (x, y) |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
881 register Lisp_Object x, y; |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
882 { |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
883 double f1, f2; |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
884 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
885 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x); |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
21514
diff
changeset
|
886 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y); |
16786
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
887 |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
888 if (! IEEE_FLOATING_POINT && f2 == 0) |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
889 Fsignal (Qarith_error, Qnil); |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
890 |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
891 /* If the "remainder" comes out with the wrong sign, fix it. */ |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
892 IN_FLOAT2 ((f1 = fmod (f1, f2), |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
893 f1 = (f2 < 0 ? f1 > 0 : f1 < 0) ? f1 + f2 : f1), |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
894 "mod", x, y); |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
895 return make_float (f1); |
8907c00c0cc6
<float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents:
16220
diff
changeset
|
896 } |
102 | 897 |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
898 /* 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
|
899 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
900 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
|
901 "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
|
902 \(Round toward +inf.\)") |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
903 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
904 register Lisp_Object arg; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
905 { |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
906 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
|
907 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
|
908 return make_float (d); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
909 } |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
910 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
911 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
|
912 "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
|
913 \(Round towards -inf.\)") |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
914 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
915 register Lisp_Object arg; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
916 { |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
917 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
|
918 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
|
919 return make_float (d); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
920 } |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
921 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
922 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
|
923 "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
|
924 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
925 register Lisp_Object arg; |
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 double d = extract_float (arg); |
19737
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
928 IN_FLOAT (d = emacs_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
|
929 return make_float (d); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
930 } |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
931 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
932 DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0, |
19737
cad2a27d4451
(emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents:
18627
diff
changeset
|
933 "Truncate a floating point number to an integral float value.\n\ |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
934 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
|
935 (arg) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
936 register Lisp_Object arg; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
937 { |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
938 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
|
939 if (d >= 0.0) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
940 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
|
941 else |
5495
87f9165f5b14
[MSDOS]: Don't define HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents:
4881
diff
changeset
|
942 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
|
943 return make_float (d); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
944 } |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
945 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
946 #ifdef FLOAT_CATCH_SIGILL |
621 | 947 static SIGTYPE |
102 | 948 float_error (signo) |
949 int signo; | |
950 { | |
951 if (! in_float) | |
952 fatal_error_signal (signo); | |
953 | |
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16207
diff
changeset
|
954 #ifdef BSD_SYSTEM |
102 | 955 #ifdef BSD4_1 |
956 sigrelse (SIGILL); | |
957 #else /* not BSD4_1 */ | |
638 | 958 sigsetmask (SIGEMPTYMASK); |
102 | 959 #endif /* not BSD4_1 */ |
485 | 960 #else |
961 /* Must reestablish handler each time it is called. */ | |
962 signal (SIGILL, float_error); | |
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16207
diff
changeset
|
963 #endif /* BSD_SYSTEM */ |
102 | 964 |
965 in_float = 0; | |
966 | |
967 Fsignal (Qarith_error, Fcons (float_error_arg, Qnil)); | |
968 } | |
969 | |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
970 /* 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
|
971 where SIGILL is signaled. */ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
972 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
973 #endif /* FLOAT_CATCH_SIGILL */ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
974 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
975 #ifdef HAVE_MATHERR |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
976 int |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
977 matherr (x) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
978 struct exception *x; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
979 { |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
980 Lisp_Object args; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
981 if (! in_float) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
982 /* 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
|
983 return 0; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
984 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
|
985 x->name = "expt"; |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
986 |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
987 args |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
988 = 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
|
989 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
|
990 ((!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
|
991 ? 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
|
992 : Qnil))); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
993 switch (x->type) |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
994 { |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
995 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
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 } |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1001 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
|
1002 } |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1003 #endif /* HAVE_MATHERR */ |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1004 |
21514 | 1005 void |
102 | 1006 init_floatfns () |
1007 { | |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1008 #ifdef FLOAT_CATCH_SIGILL |
102 | 1009 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
|
1010 #endif |
102 | 1011 in_float = 0; |
1012 } | |
1013 | |
21514 | 1014 void |
102 | 1015 syms_of_floatfns () |
1016 { | |
1017 defsubr (&Sacos); | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1018 defsubr (&Sasin); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1019 defsubr (&Satan); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1020 defsubr (&Scos); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1021 defsubr (&Ssin); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1022 defsubr (&Stan); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1023 #if 0 |
102 | 1024 defsubr (&Sacosh); |
1025 defsubr (&Sasinh); | |
1026 defsubr (&Satanh); | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1027 defsubr (&Scosh); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1028 defsubr (&Ssinh); |
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1029 defsubr (&Stanh); |
102 | 1030 defsubr (&Sbessel_y0); |
1031 defsubr (&Sbessel_y1); | |
1032 defsubr (&Sbessel_yn); | |
1033 defsubr (&Sbessel_j0); | |
1034 defsubr (&Sbessel_j1); | |
1035 defsubr (&Sbessel_jn); | |
1036 defsubr (&Serf); | |
1037 defsubr (&Serfc); | |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1038 defsubr (&Slog_gamma); |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1039 defsubr (&Scube_root); |
5595
63bc8a14a073
(Fffloor, Ffceil, Ffround, Fftruncate): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5495
diff
changeset
|
1040 #endif |
2094
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1041 defsubr (&Sfceiling); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1042 defsubr (&Sffloor); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1043 defsubr (&Sfround); |
c77607f8e32d
(FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents:
1918
diff
changeset
|
1044 defsubr (&Sftruncate); |
102 | 1045 defsubr (&Sexp); |
683
7f4d77d29804
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
638
diff
changeset
|
1046 defsubr (&Sexpt); |
102 | 1047 defsubr (&Slog); |
1048 defsubr (&Slog10); | |
1049 defsubr (&Ssqrt); | |
1050 | |
1051 defsubr (&Sabs); | |
1052 defsubr (&Sfloat); | |
1053 defsubr (&Slogb); | |
1054 defsubr (&Sceiling); | |
16857
bdafa1f28a64
(rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents:
16786
diff
changeset
|
1055 defsubr (&Sfloor); |
102 | 1056 defsubr (&Sround); |
1057 defsubr (&Struncate); | |
1058 } |