annotate src/floatfns.c @ 109026:c138aa96dae8

Add preliminary describe-package functionality, and some cleanup. * help-mode.el (help-package-def): New button type. * menu-bar.el: Move package-list-packages binding here from package.el. * emacs-lisp/package.el: Move package-list-packages binding to menu-bar.el. (describe-package, describe-package-1, package--dir): New funs. (package-activate-1): Use package--dir. * emacs-lisp/package-x.el (gnus-article-buffer): Require package.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 19 Jun 2010 18:36:51 -0400
parents 767894eefe6c
children c25c24812fb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1 /* Primitive operations on floating point for GNU Emacs Lisp interpreter.
75227
e90d04cd455a Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 71978
diff changeset
2 Copyright (C) 1988, 1993, 1994, 1999, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
4
101107
1a4b4aa37d68 Comment (add Author:, based on ack.texi).
Glenn Morris <rgm@gnu.org>
parents: 100951
diff changeset
5 Author: Wolfgang Rupprecht
1a4b4aa37d68 Comment (add Author:, based on ack.texi).
Glenn Morris <rgm@gnu.org>
parents: 100951
diff changeset
6 (according to ack.texi)
1a4b4aa37d68 Comment (add Author:, based on ack.texi).
Glenn Morris <rgm@gnu.org>
parents: 100951
diff changeset
7
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
8 This file is part of GNU Emacs.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
9
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
10 GNU Emacs is free software: you can redistribute it and/or modify
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
11 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
12 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
13 (at your option) any later version.
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
14
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
15 GNU Emacs is distributed in the hope that it will be useful,
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
18 GNU General Public License for more details.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
19
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
21 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
22
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
23
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
24 /* 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
25 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
26 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
27
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
28 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
29 Define HAVE_CBRT if you have cbrt.
19737
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
30 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
31 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
32
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
33 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
34 (This should happen automatically.)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
35
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
36 Define FLOAT_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
37 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
38
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
39 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
40 (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
41
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
42 Define FLOAT_CHECK_DOMAIN if the float library doesn't handle errors by
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13442
diff changeset
43 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
44 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
45 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
46 a domain error occurs.)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
47 */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
48
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25645
diff changeset
49 #include <config.h>
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
50 #include <signal.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 101107
diff changeset
51 #include <setjmp.h>
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
52 #include "lisp.h"
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
53 #include "syssignal.h"
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
54
20122
923e1f635ace No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents: 19737
diff changeset
55 #if STDC_HEADERS
923e1f635ace No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents: 19737
diff changeset
56 #include <float.h>
923e1f635ace No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents: 19737
diff changeset
57 #endif
923e1f635ace No need to include <float.h> before "lisp.h",
Paul Eggert <eggert@twinsun.com>
parents: 19737
diff changeset
58
16786
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
59 /* 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
60 #ifndef IEEE_FLOATING_POINT
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
61 #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
62 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
63 #define IEEE_FLOATING_POINT 1
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
64 #else
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
65 #define IEEE_FLOATING_POINT 0
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
66 #endif
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
67 #endif
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
68
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
69 #include <math.h>
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
70
4881
e53d4ae93675 Declare `logb' only if HAVE_LOGB is defined.
Brian Fox <bfox@gnu.org>
parents: 4843
diff changeset
71 /* 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
72 #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
73 extern double logb ();
7448
bf93ac2d8409 Don't declare logb if it is a macro.
Richard M. Stallman <rms@gnu.org>
parents: 7361
diff changeset
74 #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
75
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
76 #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
77 /* 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
78 # ifndef HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
79 # define HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
80 # endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
81 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
82
3027
7ed290bef028 Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents: 3025
diff changeset
83 #ifdef NO_MATHERR
3025
d09f68ccd145 [NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
84 #undef HAVE_MATHERR
d09f68ccd145 [NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
85 #endif
d09f68ccd145 [NO_MATHERR]: Undef HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
86
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
87 #ifdef HAVE_MATHERR
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
88 # ifdef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
89 # undef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
90 # endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
91 # ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
92 # undef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
93 # endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
94 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
95
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
96 #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
97 #define FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
98 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
99
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
100 #ifdef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
101 # include <errno.h>
31095
e19d38e14720 [USE_CRT_DLL]: Remove unnecessary extern, which screws
Andrew Innes <andrewi@gnu.org>
parents: 27727
diff changeset
102 #endif
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
103
39814
a9c8422074c9 float_error() is defined iff FLOAT_CATCH_SIGILL is defined.
Pavel Janík <Pavel@Janik.cz>
parents: 39638
diff changeset
104 #ifdef FLOAT_CATCH_SIGILL
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
105 static SIGTYPE float_error ();
39814
a9c8422074c9 float_error() is defined iff FLOAT_CATCH_SIGILL is defined.
Pavel Janík <Pavel@Janik.cz>
parents: 39638
diff changeset
106 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
107
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
108 /* Nonzero while executing in floating point.
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
109 This tells float_error what to do. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
110
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
111 static int in_float;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
112
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
113 /* If an argument is out of range for a mathematical function,
16207
f414d3a2fd58 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 15694
diff changeset
114 here is the actual argument value to use in the error message.
f414d3a2fd58 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 15694
diff changeset
115 These variables are used only across the floating point library call
f414d3a2fd58 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 15694
diff changeset
116 so there is no need to staticpro them. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
117
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
118 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
119
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
120 static char *float_error_fn_name;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
121
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
122 /* Evaluate the floating point expression D, recording NUM
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
123 as the original argument for error messages.
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
124 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
125 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
126
699ae3079c09 * floatfns.c (Flogb): Always implement this by calling Flog, even
Jim Blandy <jimb@redhat.com>
parents: 1715
diff changeset
127 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
128 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
129 check properly. */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
130
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
131 #ifdef FLOAT_CHECK_ERRNO
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
132 #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
133 do { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
134 float_error_arg = num; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
135 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
136 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
137 switch (errno) { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
138 case 0: break; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
139 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
140 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
141 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
142 } \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
143 } while (0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
144 #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
145 do { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
146 float_error_arg = num; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
147 float_error_arg2 = num2; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
148 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
149 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
150 switch (errno) { \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
151 case 0: break; \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
152 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
153 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
154 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
155 } \
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
156 } while (0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
157 #else
3407
d00aaf536bfd [!FLOAT_CHECK_ERRNO] (IN_FLOAT): New definition.
Richard M. Stallman <rms@gnu.org>
parents: 3094
diff changeset
158 #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
159 #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
160 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
161
6375
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
162 /* 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
163 using the given arguments. */
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
164 #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
165 do \
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
166 { \
39638
911382113c16 (FLOAT_TO_INT2, FLOAT_TO_INT): Use FIXNUM_OVERFLOW_P.
Gerd Moellmann <gerd@gnu.org>
parents: 31095
diff changeset
167 if (FIXNUM_OVERFLOW_P (x)) \
6375
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
168 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
169 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
170 } \
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
171 while (0)
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
172 #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
173 do \
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
174 { \
39638
911382113c16 (FLOAT_TO_INT2, FLOAT_TO_INT): Use FIXNUM_OVERFLOW_P.
Gerd Moellmann <gerd@gnu.org>
parents: 31095
diff changeset
175 if (FIXNUM_OVERFLOW_P (x)) \
6375
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
176 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
177 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
178 } \
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
179 while (0)
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
180
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
181 #define arith_error(op,arg) \
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
182 xsignal2 (Qarith_error, build_string ((op)), (arg))
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
183 #define range_error(op,arg) \
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
184 xsignal2 (Qrange_error, build_string ((op)), (arg))
6375
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
185 #define range_error2(op,a1,a2) \
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
186 xsignal3 (Qrange_error, build_string ((op)), (a1), (a2))
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
187 #define domain_error(op,arg) \
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
188 xsignal2 (Qdomain_error, build_string ((op)), (arg))
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
189 #define domain_error2(op,a1,a2) \
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
190 xsignal3 (Qdomain_error, build_string ((op)), (a1), (a2))
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
191
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
192 /* Extract a Lisp number as a `double', or signal an error. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
193
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
194 double
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
195 extract_float (num)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
196 Lisp_Object num;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
197 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
198 CHECK_NUMBER_OR_FLOAT (num);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
199
9129
b2d1d925d5cc (extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents: 8825
diff changeset
200 if (FLOATP (num))
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 21514
diff changeset
201 return XFLOAT_DATA (num);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
202 return (double) XINT (num);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
203 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
204
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
205 /* Trig functions. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
206
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
207 DEFUN ("acos", Facos, Sacos, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
208 doc: /* Return the inverse cosine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
209 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
210 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
211 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
212 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
213 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
214 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
215 domain_error ("acos", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
216 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
217 IN_FLOAT (d = acos (d), "acos", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
218 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
219 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
220
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
221 DEFUN ("asin", Fasin, Sasin, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
222 doc: /* Return the inverse sine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
223 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
224 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
225 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
226 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
227 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
228 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
229 domain_error ("asin", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
230 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
231 IN_FLOAT (d = asin (d), "asin", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
232 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
233 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
234
43413
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
235 DEFUN ("atan", Fatan, Satan, 1, 2, 0,
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
236 doc: /* Return the inverse tangent of the arguments.
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
237 If only one argument Y is given, return the inverse tangent of Y.
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
238 If two arguments Y and X are given, return the inverse tangent of Y
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
239 divided by X, i.e. the angle in radians between the vector (X, Y)
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
240 and the x-axis. */)
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
241 (y, x)
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
242 register Lisp_Object y, x;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
243 {
43413
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
244 double d = extract_float (y);
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
245
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
246 if (NILP (x))
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
247 IN_FLOAT (d = atan (d), "atan", y);
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
248 else
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
249 {
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
250 double d2 = extract_float (x);
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
251
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
252 IN_FLOAT2 (d = atan2 (d, d2), "atan", y, x);
0f448bd1bf9a (Fatan): Accept an optional second arg and call atan2 if passed 2 args.
Eli Zaretskii <eliz@gnu.org>
parents: 43189
diff changeset
253 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
254 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
255 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
256
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
257 DEFUN ("cos", Fcos, Scos, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
258 doc: /* Return the cosine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
259 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
260 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
261 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
262 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
263 IN_FLOAT (d = cos (d), "cos", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
264 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
265 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
266
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
267 DEFUN ("sin", Fsin, Ssin, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
268 doc: /* Return the sine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
269 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
270 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
271 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
272 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
273 IN_FLOAT (d = sin (d), "sin", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
274 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
275 }
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 DEFUN ("tan", Ftan, Stan, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
278 doc: /* Return the tangent of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
279 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
280 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
281 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
282 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
283 double c = cos (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
284 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
285 if (c == 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
286 domain_error ("tan", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
287 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
288 IN_FLOAT (d = sin (d) / c, "tan", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
289 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
290 }
108307
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
291
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
292 #if defined HAVE_ISNAN && defined HAVE_COPYSIGN
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
293 DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
294 doc: /* Return non nil iff argument X is a NaN. */)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
295 (x)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
296 Lisp_Object x;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
297 {
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
298 CHECK_FLOAT (x);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
299 return isnan (XFLOAT_DATA (x)) ? Qt : Qnil;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
300 }
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
301
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
302 DEFUN ("copysign", Fcopysign, Scopysign, 1, 2, 0,
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
303 doc: /* Copy sign of X2 to value of X1, and return the result.
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
304 Cause an error if X1 or X2 is not a float. */)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
305 (x1, x2)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
306 Lisp_Object x1, x2;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
307 {
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
308 double f1, f2;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
309
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
310 CHECK_FLOAT (x1);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
311 CHECK_FLOAT (x2);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
312
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
313 f1 = XFLOAT_DATA (x1);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
314 f2 = XFLOAT_DATA (x2);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
315
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
316 return make_float (copysign (f1, f2));
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
317 }
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
318
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
319 DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0,
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
320 doc: /* Get significand and exponent of a floating point number.
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
321 Breaks the floating point number X into its binary significand SGNFCAND
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
322 \(a floating point value between 0.5 (included) and 1.0 (excluded))
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
323 and an integral exponent EXP for 2, such that:
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
324
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
325 X = SGNFCAND * 2^EXP
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
326
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
327 The function returns the cons cell (SGNFCAND . EXP).
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
328 If X is zero, both parts (SGNFCAND and EXP) are zero. */)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
329 (x)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
330 Lisp_Object x;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
331 {
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
332 double f = XFLOATINT (x);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
333
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
334 if (f == 0.0)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
335 return Fcons (make_float (0.0), make_number (0));
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
336 else
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
337 {
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
338 int exp;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
339 double sgnfcand = frexp (f, &exp);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
340 return Fcons (make_float (sgnfcand), make_number (exp));
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
341 }
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
342 }
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
343
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
344 DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0,
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
345 doc: /* Construct number X from significand SGNFCAND and exponent EXP.
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
346 Returns the floating point value resulting from multiplying SGNFCAND
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
347 (the significand) by 2 raised to the power of EXP (the exponent). */)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
348 (sgnfcand, exp)
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
349 Lisp_Object sgnfcand, exp;
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
350 {
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
351 CHECK_NUMBER (exp);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
352 return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exp)));
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
353 }
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
354 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
355
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
356 #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
357
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
358 DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
359 doc: /* Return the bessel function j0 of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
360 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
361 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
362 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
363 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
364 IN_FLOAT (d = j0 (d), "bessel-j0", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
365 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
366 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
367
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
368 DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
369 doc: /* Return the bessel function j1 of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
370 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
371 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
372 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
373 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
374 IN_FLOAT (d = j1 (d), "bessel-j1", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
375 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
376 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
377
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
378 DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
379 doc: /* Return the order N bessel function output jn of ARG.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
380 The first arg (the order) is truncated to an integer. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
381 (n, arg)
14076
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
382 register Lisp_Object n, arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
383 {
14076
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
384 int i1 = extract_float (n);
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
385 double f2 = extract_float (arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
386
14076
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
387 IN_FLOAT (f2 = jn (i1, f2), "bessel-jn", n);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
388 return make_float (f2);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
389 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
390
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
391 DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
392 doc: /* Return the bessel function y0 of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
393 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
394 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
395 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
396 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
397 IN_FLOAT (d = y0 (d), "bessel-y0", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
398 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
399 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
400
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
401 DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
402 doc: /* Return the bessel function y1 of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
403 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
404 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
405 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
406 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
407 IN_FLOAT (d = y1 (d), "bessel-y0", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
408 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
409 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
410
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
411 DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
412 doc: /* Return the order N bessel function output yn of ARG.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
413 The first arg (the order) is truncated to an integer. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
414 (n, arg)
14076
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
415 register Lisp_Object n, arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
416 {
14076
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
417 int i1 = extract_float (n);
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
418 double f2 = extract_float (arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
419
14076
b339e9aaea4b (Fbessel_jn, Fbessel_yn): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
420 IN_FLOAT (f2 = yn (i1, f2), "bessel-yn", n);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
421 return make_float (f2);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
422 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
423
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
424 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
425
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
426 #if 0 /* Leave these out unless we see they are worth having. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
427
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
428 DEFUN ("erf", Ferf, Serf, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
429 doc: /* Return the mathematical error function of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
430 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
431 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
432 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
433 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
434 IN_FLOAT (d = erf (d), "erf", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
435 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
436 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
437
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
438 DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
439 doc: /* Return the complementary error function of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
440 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
441 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
442 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
443 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
444 IN_FLOAT (d = erfc (d), "erfc", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
445 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
446 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
447
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
448 DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
449 doc: /* Return the log gamma of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
450 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
451 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
452 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
453 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
454 IN_FLOAT (d = lgamma (d), "log-gamma", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
455 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
456 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
457
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
458 DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
459 doc: /* Return the cube root of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
460 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
461 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
462 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
463 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
464 #ifdef HAVE_CBRT
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
465 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
466 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
467 if (d >= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
468 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
469 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
470 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
471 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
472 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
473 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
474
694
714b8017cc6b entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 683
diff changeset
475 #endif
714b8017cc6b entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 683
diff changeset
476
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
477 DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
478 doc: /* Return the exponential base e of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
479 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
480 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
481 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
482 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
483 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
484 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
485 range_error ("exp", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
486 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
487 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
488 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
489 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
490 IN_FLOAT (d = exp (d), "exp", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
491 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
492 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
493
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
494 DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
495 doc: /* Return the exponential ARG1 ** ARG2. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
496 (arg1, arg2)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
497 register Lisp_Object arg1, arg2;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
498 {
84998
259a9fdd1450 (Fexpt): Manually check for overflows, so that a power
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 78260
diff changeset
499 double f1, f2, f3;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
500
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
501 CHECK_NUMBER_OR_FLOAT (arg1);
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
502 CHECK_NUMBER_OR_FLOAT (arg2);
9129
b2d1d925d5cc (extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents: 8825
diff changeset
503 if (INTEGERP (arg1) /* common lisp spec */
64810
3529fe766935 (Fexpt): Use floats for negative exponent.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64778
diff changeset
504 && INTEGERP (arg2) /* don't promote, if both are ints, and */
3529fe766935 (Fexpt): Use floats for negative exponent.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64778
diff changeset
505 && 0 <= XINT (arg2)) /* we are sure the result is not fractional */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
506 { /* 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
507 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
508 Lisp_Object val;
8ab0a7453577 (Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
509
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
510 x = XINT (arg1);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
511 y = XINT (arg2);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
512 acc = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43413
diff changeset
513
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
514 if (y < 0)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
515 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
516 if (x == 1)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
517 acc = 1;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
518 else if (x == -1)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
519 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
520 else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
521 acc = 0;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
522 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
523 else
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
524 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
525 while (y > 0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
526 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
527 if (y & 1)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
528 acc *= x;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
529 x *= x;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
530 y = (unsigned)y >> 1;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
531 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
532 }
9267
1b685d477c10 (FLOAT_TO_INT, FLOAT_TO_INT2, Fexpt, Flogb, Ffloor): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents: 9129
diff changeset
533 XSETINT (val, acc);
3673
8ab0a7453577 (Fexpt): New local `val' for making integer to return.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
534 return val;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
535 }
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 21514
diff changeset
536 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
537 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
538 /* 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
539 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
540 f1 = 1.0;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
541 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
542 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
543 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
544 #endif
84998
259a9fdd1450 (Fexpt): Manually check for overflows, so that a power
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 78260
diff changeset
545 IN_FLOAT2 (f3 = pow (f1, f2), "expt", arg1, arg2);
259a9fdd1450 (Fexpt): Manually check for overflows, so that a power
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 78260
diff changeset
546 /* Check for overflow in the result. */
259a9fdd1450 (Fexpt): Manually check for overflows, so that a power
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 78260
diff changeset
547 if (f1 != 0.0 && f3 == 0.0)
259a9fdd1450 (Fexpt): Manually check for overflows, so that a power
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 78260
diff changeset
548 range_error ("expt", arg1);
259a9fdd1450 (Fexpt): Manually check for overflows, so that a power
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 78260
diff changeset
549 return make_float (f3);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
550 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
551
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
552 DEFUN ("log", Flog, Slog, 1, 2, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
553 doc: /* Return the natural logarithm of ARG.
67496
199bdb85a35f (Flog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 64810
diff changeset
554 If the optional argument BASE is given, return log ARG using that base. */)
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
555 (arg, base)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
556 register Lisp_Object arg, base;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
557 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
558 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
559
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
560 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
561 if (d <= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
562 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
563 #endif
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
564 if (NILP (base))
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
565 IN_FLOAT (d = log (d), "log", arg);
1005
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
566 else
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
567 {
70ed307d9047 * floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
Jim Blandy <jimb@redhat.com>
parents: 694
diff changeset
568 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
569
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
570 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
571 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
572 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
573 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
574 if (b == 10.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
575 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
576 else
3407
d00aaf536bfd [!FLOAT_CHECK_ERRNO] (IN_FLOAT): New definition.
Richard M. Stallman <rms@gnu.org>
parents: 3094
diff changeset
577 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
578 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
579 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
580 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
581
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
582 DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
583 doc: /* Return the logarithm base 10 of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
584 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
585 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
586 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
587 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
588 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
589 if (d <= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
590 domain_error ("log10", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
591 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
592 IN_FLOAT (d = log10 (d), "log10", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
593 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
594 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
595
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
596 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
597 doc: /* Return the square root of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
598 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
599 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
600 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
601 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
602 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
603 if (d < 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
604 domain_error ("sqrt", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
605 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
606 IN_FLOAT (d = sqrt (d), "sqrt", arg);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
607 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
608 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
609
694
714b8017cc6b entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 683
diff changeset
610 #if 0 /* Not clearly worth adding. */
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
611
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
612 DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
613 doc: /* Return the inverse hyperbolic cosine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
614 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
615 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
616 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
617 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
618 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
619 if (d < 1.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
620 domain_error ("acosh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
621 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
622 #ifdef HAVE_INVERSE_HYPERBOLIC
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
623 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
624 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
625 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
626 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
627 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
628 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
629
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
630 DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
631 doc: /* Return the inverse hyperbolic sine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
632 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
633 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
634 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
635 double d = extract_float (arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
636 #ifdef HAVE_INVERSE_HYPERBOLIC
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
637 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
638 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
639 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
640 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
641 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
642 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
643
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
644 DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
645 doc: /* Return the inverse hyperbolic tangent of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
646 (arg)
2094
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;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
648 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
649 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
650 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
651 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
652 domain_error ("atanh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
653 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
654 #ifdef HAVE_INVERSE_HYPERBOLIC
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
655 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
656 #else
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
657 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
658 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
659 return make_float (d);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
660 }
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
661
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
662 DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
663 doc: /* Return the hyperbolic cosine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
664 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
665 register Lisp_Object arg;
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
666 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
667 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
668 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
669 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
670 range_error ("cosh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
671 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
672 IN_FLOAT (d = cosh (d), "cosh", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
673 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
674 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
675
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
676 DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
677 doc: /* Return the hyperbolic sine of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
678 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
679 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
680 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
681 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
682 #ifdef FLOAT_CHECK_DOMAIN
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
683 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
684 range_error ("sinh", arg);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
685 #endif
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
686 IN_FLOAT (d = sinh (d), "sinh", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
687 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
688 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
689
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
690 DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
691 doc: /* Return the hyperbolic tangent of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
692 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
693 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
694 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
695 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
696 IN_FLOAT (d = tanh (d), "tanh", arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
697 return make_float (d);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
698 }
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
699 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
700
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
701 DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
702 doc: /* Return the absolute value of ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
703 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
704 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
705 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
706 CHECK_NUMBER_OR_FLOAT (arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
707
9129
b2d1d925d5cc (extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents: 8825
diff changeset
708 if (FLOATP (arg))
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 21514
diff changeset
709 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
710 else if (XINT (arg) < 0)
9365
0b431684f97b (Fabs): Don't use XFASTINT when negative.
Karl Heuer <kwzh@gnu.org>
parents: 9267
diff changeset
711 XSETINT (arg, - XINT (arg));
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
712
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
713 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
714 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
715
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
716 DEFUN ("float", Ffloat, Sfloat, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
717 doc: /* Return the floating point number equal to ARG. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
718 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
719 register Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
720 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
721 CHECK_NUMBER_OR_FLOAT (arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
722
9129
b2d1d925d5cc (extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents: 8825
diff changeset
723 if (INTEGERP (arg))
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
724 return make_float ((double) XINT (arg));
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
725 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
726 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
727 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
728
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
729 DEFUN ("logb", Flogb, Slogb, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
730 doc: /* Returns largest integer <= the base 2 log of the magnitude of ARG.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
731 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
732 (arg)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
733 Lisp_Object arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
734 {
2119
4077ef8ad483 * floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents: 2094
diff changeset
735 Lisp_Object val;
11265
b2291296ec87 (Flogb): Use EMACS_INT for `value'.
Richard M. Stallman <rms@gnu.org>
parents: 9365
diff changeset
736 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
737 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
738
6359
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
739 if (f == 0.0)
53002
3e336113348d (Flogb): Don't use VALMASK.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
740 value = MOST_NEGATIVE_FIXNUM;
6359
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
741 else
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
742 {
4501
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
743 #ifdef HAVE_LOGB
6359
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
744 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
745 #else
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
746 #ifdef HAVE_FREXP
11859
8d57babf4b36 (Flogb): frexp needs a pointer to int, not EMACS_INT.
Karl Heuer <kwzh@gnu.org>
parents: 11265
diff changeset
747 int ivalue;
8d57babf4b36 (Flogb): frexp needs a pointer to int, not EMACS_INT.
Karl Heuer <kwzh@gnu.org>
parents: 11265
diff changeset
748 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
749 value = ivalue - 1;
2205
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
750 #else
6359
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
751 int i;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
752 double d;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
753 if (f < 0.0)
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
754 f = -f;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
755 value = -1;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
756 while (f < 0.5)
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
757 {
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
758 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
759 d *= d;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
760 f /= d;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
761 value -= i;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
762 }
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
763 while (f >= 1.0)
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
764 {
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
765 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
766 d *= d;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
767 f /= d;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
768 value += i;
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
769 }
4501
9352d7d021c2 * config.h.in (HAVE_LOGB, HAVE_FREXP): Add #undefs for the
Jim Blandy <jimb@redhat.com>
parents: 3673
diff changeset
770 #endif
2205
c021f53fe7e5 * floatfns.c (logb): Add extern declaration for this.
Jim Blandy <jimb@redhat.com>
parents: 2129
diff changeset
771 #endif
6359
800c035273e9 (Flogb): Check for 0.0. Emulate logb if needed.
Karl Heuer <kwzh@gnu.org>
parents: 6314
diff changeset
772 }
9267
1b685d477c10 (FLOAT_TO_INT, FLOAT_TO_INT2, Fexpt, Flogb, Ffloor): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents: 9129
diff changeset
773 XSETINT (val, value);
2119
4077ef8ad483 * floatfns.c (Flogb): Undo the change of Feb 22.
Jim Blandy <jimb@redhat.com>
parents: 2094
diff changeset
774 return val;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
775 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
776
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
777
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
778 /* the rounding functions */
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
779
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
780 static Lisp_Object
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
781 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
782 register Lisp_Object arg, divisor;
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
783 double (*double_round) ();
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
784 EMACS_INT (*int_round2) ();
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
785 char *name;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
786 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
787 CHECK_NUMBER_OR_FLOAT (arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
788
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
789 if (! NILP (divisor))
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
790 {
12537
476296adb950 (Fexpt): Use EMACS_INT for integer calculation.
Karl Heuer <kwzh@gnu.org>
parents: 11859
diff changeset
791 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
792
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39814
diff changeset
793 CHECK_NUMBER_OR_FLOAT (divisor);
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
794
9129
b2d1d925d5cc (extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents: 8825
diff changeset
795 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
796 {
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
797 double f1, f2;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
798
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 21514
diff changeset
799 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
800 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
801 if (! IEEE_FLOATING_POINT && f2 == 0)
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
802 xsignal0 (Qarith_error);
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
803
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
804 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
805 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
806 return arg;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
807 }
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
808
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
809 i1 = XINT (arg);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
810 i2 = XINT (divisor);
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
811
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
812 if (i2 == 0)
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
813 xsignal0 (Qarith_error);
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
814
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
815 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
816 return arg;
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
817 }
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
818
9129
b2d1d925d5cc (extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
Karl Heuer <kwzh@gnu.org>
parents: 8825
diff changeset
819 if (FLOATP (arg))
6375
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
820 {
212dcd2c06e4 (FLOAT_TO_INT, FLOAT_TO_INT2, range_error2): New macros.
Karl Heuer <kwzh@gnu.org>
parents: 6359
diff changeset
821 double d;
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
822
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 21514
diff changeset
823 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
824 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
825 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
826
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
827 return arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
828 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
829
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
830 /* 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
831 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
832 integer functions. */
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
833
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
834 static EMACS_INT
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
835 ceiling2 (i1, i2)
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
836 EMACS_INT i1, i2;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
837 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
838 return (i2 < 0
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
839 ? (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
840 : (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
841 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
842
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
843 static EMACS_INT
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
844 floor2 (i1, i2)
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
845 EMACS_INT i1, i2;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
846 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
847 return (i2 < 0
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
848 ? (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
849 : (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
850 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
851
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
852 static EMACS_INT
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
853 truncate2 (i1, i2)
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
854 EMACS_INT i1, i2;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
855 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
856 return (i2 < 0
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
857 ? (i1 < 0 ? -i1 / -i2 : - (i1 / -i2))
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
858 : (i1 < 0 ? - (-i1 / i2) : i1 / i2));
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
859 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
860
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
861 static EMACS_INT
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
862 round2 (i1, i2)
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
863 EMACS_INT i1, i2;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
864 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
865 /* 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
866 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
867 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
868 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
869 odd. */
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
870 EMACS_INT q = i1 / i2;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
871 EMACS_INT r = i1 % i2;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
872 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
873 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
874 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
875 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
876
19737
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
877 /* 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
878 if `rint' exists but does not work right. */
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
879 #ifdef HAVE_RINT
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
880 #define emacs_rint rint
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
881 #else
16929
a6b5ec9a51b4 [!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents: 16857
diff changeset
882 static double
19737
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
883 emacs_rint (d)
16929
a6b5ec9a51b4 [!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents: 16857
diff changeset
884 double d;
a6b5ec9a51b4 [!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents: 16857
diff changeset
885 {
16956
bfa27111d35b Whitespace change.
Richard M. Stallman <rms@gnu.org>
parents: 16929
diff changeset
886 return floor (d + 0.5);
16929
a6b5ec9a51b4 [!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents: 16857
diff changeset
887 }
a6b5ec9a51b4 [!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents: 16857
diff changeset
888 #endif
a6b5ec9a51b4 [!HAVE_RINT] (rint): Convert macro to an actual
Karl Heuer <kwzh@gnu.org>
parents: 16857
diff changeset
889
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
890 static double
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
891 double_identity (d)
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
892 double d;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
893 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
894 return d;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
895 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
896
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
897 DEFUN ("ceiling", Fceiling, Sceiling, 1, 2, 0,
41028
e4bce1db7f77 (Fceiling, Ffloor): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 41001
diff changeset
898 doc: /* Return the smallest integer no less than ARG.
e4bce1db7f77 (Fceiling, Ffloor): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 41001
diff changeset
899 This rounds the value towards +inf.
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
900 With optional DIVISOR, return the smallest integer no less than ARG/DIVISOR. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
901 (arg, divisor)
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
902 Lisp_Object arg, divisor;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
903 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
904 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
905 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
906
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
907 DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0,
41028
e4bce1db7f77 (Fceiling, Ffloor): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 41001
diff changeset
908 doc: /* Return the largest integer no greater than ARG.
60651
de22fdff5bad (Ffloor): Doc fix.
Lute Kamstra <lute@gnu.org>
parents: 58986
diff changeset
909 This rounds the value towards -inf.
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
910 With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
911 (arg, divisor)
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
912 Lisp_Object arg, divisor;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
913 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
914 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
915 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
916
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
917 DEFUN ("round", Fround, Sround, 1, 2, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
918 doc: /* Return the nearest integer to ARG.
43179
b8eac678ad15 (Fround): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 41028
diff changeset
919 With optional DIVISOR, return the nearest integer to ARG/DIVISOR.
b8eac678ad15 (Fround): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 41028
diff changeset
920
43181
0f5eacbb65d9 (Fround): A better doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 43179
diff changeset
921 Rounding a value equidistant between two integers may choose the
0f5eacbb65d9 (Fround): A better doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 43179
diff changeset
922 integer closer to zero, or it may prefer an even integer, depending on
0f5eacbb65d9 (Fround): A better doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 43179
diff changeset
923 your machine. For example, \(round 2.5\) can return 3 on some
43189
004354581e54 (Fround): Fix a typo.
Eli Zaretskii <eliz@gnu.org>
parents: 43181
diff changeset
924 systems, but 2 on others. */)
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
925 (arg, divisor)
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
926 Lisp_Object arg, divisor;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
927 {
19737
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
928 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
929 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
930
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
931 DEFUN ("truncate", Ftruncate, Struncate, 1, 2, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
932 doc: /* Truncate a floating point number to an int.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
933 Rounds ARG toward zero.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
934 With optional DIVISOR, truncate ARG/DIVISOR. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
935 (arg, divisor)
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
936 Lisp_Object arg, divisor;
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
937 {
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
938 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
939 "truncate");
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
940 }
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
941
4506
6131dad14f6f (Ffloor): Optional second operand specifies divisor, as in Common Lisp.
Paul Eggert <eggert@twinsun.com>
parents: 4501
diff changeset
942
16786
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
943 Lisp_Object
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
944 fmod_float (x, y)
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
945 register Lisp_Object x, y;
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
946 {
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
947 double f1, f2;
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
948
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 21514
diff changeset
949 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
950 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
951
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
952 if (! IEEE_FLOATING_POINT && f2 == 0)
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
953 xsignal0 (Qarith_error);
16786
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
954
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
955 /* 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
956 IN_FLOAT2 ((f1 = fmod (f1, f2),
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
957 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
958 "mod", x, y);
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
959 return make_float (f1);
8907c00c0cc6 <float.h>: Include if STDC_HEADERS.
Paul Eggert <eggert@twinsun.com>
parents: 16220
diff changeset
960 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
961
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
962 /* 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
963
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
964 DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
965 doc: /* Return the smallest integer no less than ARG, as a float.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
966 \(Round toward +inf.\) */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
967 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
968 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
969 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
970 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
971 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
972 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
973 }
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 DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
976 doc: /* Return the largest integer no greater than ARG, as a float.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
977 \(Round towards -inf.\) */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
978 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
979 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
980 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
981 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
982 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
983 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
984 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
985
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
986 DEFUN ("fround", Ffround, Sfround, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
987 doc: /* Return the nearest integer to ARG, as a float. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
988 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
989 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
990 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
991 double d = extract_float (arg);
19737
cad2a27d4451 (emacs_rint): Define this,
Richard M. Stallman <rms@gnu.org>
parents: 18627
diff changeset
992 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
993 return make_float (d);
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
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
996 DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0,
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
997 doc: /* Truncate a floating point number to an integral float value.
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
998 Rounds the value toward zero. */)
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
999 (arg)
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1000 register Lisp_Object arg;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1001 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1002 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
1003 if (d >= 0.0)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1004 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
1005 else
5495
87f9165f5b14 [MSDOS]: Don't define HAVE_MATHERR.
Richard M. Stallman <rms@gnu.org>
parents: 4881
diff changeset
1006 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
1007 return make_float (d);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1008 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1009
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1010 #ifdef FLOAT_CATCH_SIGILL
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1011 static SIGTYPE
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1012 float_error (signo)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1013 int signo;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1014 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1015 if (! in_float)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1016 fatal_error_signal (signo);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1017
16220
02044b05d8e0 Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents: 16207
diff changeset
1018 #ifdef BSD_SYSTEM
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
1019 sigsetmask (SIGEMPTYMASK);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
1020 #else
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
1021 /* Must reestablish handler each time it is called. */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
1022 signal (SIGILL, float_error);
16220
02044b05d8e0 Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents: 16207
diff changeset
1023 #endif /* BSD_SYSTEM */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1024
58986
59945307b86b * syssignal.h: Declare main_thread.
Jan Djärv <jan.h.d@swipnet.se>
parents: 53002
diff changeset
1025 SIGNAL_THREAD_CHECK (signo);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1026 in_float = 0;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1027
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
1028 xsignal1 (Qarith_error, float_error_arg);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1029 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1030
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1031 /* 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
1032 where SIGILL is signaled. */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1033
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1034 #endif /* FLOAT_CATCH_SIGILL */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1035
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1036 #ifdef HAVE_MATHERR
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43413
diff changeset
1037 int
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1038 matherr (x)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1039 struct exception *x;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1040 {
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1041 Lisp_Object args;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1042 if (! in_float)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1043 /* 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
1044 return 0;
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1045 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
1046 x->name = "expt";
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1047
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1048 args
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1049 = 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
1050 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
1051 ((!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
1052 ? 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
1053 : Qnil)));
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1054 switch (x->type)
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1055 {
71978
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
1056 case DOMAIN: xsignal (Qdomain_error, args); break;
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
1057 case SING: xsignal (Qsingularity_error, args); break;
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
1058 case OVERFLOW: xsignal (Qoverflow_error, args); break;
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
1059 case UNDERFLOW: xsignal (Qunderflow_error, args); break;
6b2f430f5341 (arith_error, range_error, domain_error): Use xsignal2.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
1060 default: xsignal (Qarith_error, args); break;
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1061 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1062 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
1063 }
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1064 #endif /* HAVE_MATHERR */
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1065
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 20122
diff changeset
1066 void
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1067 init_floatfns ()
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1068 {
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1069 #ifdef FLOAT_CATCH_SIGILL
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1070 signal (SIGILL, float_error);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43413
diff changeset
1071 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1072 in_float = 0;
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1073 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1074
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 20122
diff changeset
1075 void
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1076 syms_of_floatfns ()
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1077 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1078 defsubr (&Sacos);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1079 defsubr (&Sasin);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1080 defsubr (&Satan);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1081 defsubr (&Scos);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1082 defsubr (&Ssin);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1083 defsubr (&Stan);
108307
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
1084 #if defined HAVE_ISNAN && defined HAVE_COPYSIGN
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
1085 defsubr (&Sisnan);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
1086 defsubr (&Scopysign);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
1087 defsubr (&Sfrexp);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
1088 defsubr (&Sldexp);
767894eefe6c * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107737
diff changeset
1089 #endif
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1090 #if 0
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1091 defsubr (&Sacosh);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1092 defsubr (&Sasinh);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1093 defsubr (&Satanh);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1094 defsubr (&Scosh);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1095 defsubr (&Ssinh);
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1096 defsubr (&Stanh);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1097 defsubr (&Sbessel_y0);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1098 defsubr (&Sbessel_y1);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1099 defsubr (&Sbessel_yn);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1100 defsubr (&Sbessel_j0);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1101 defsubr (&Sbessel_j1);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1102 defsubr (&Sbessel_jn);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1103 defsubr (&Serf);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1104 defsubr (&Serfc);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1105 defsubr (&Slog_gamma);
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1106 defsubr (&Scube_root);
5595
63bc8a14a073 (Fffloor, Ffceil, Ffround, Fftruncate): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 5495
diff changeset
1107 #endif
2094
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1108 defsubr (&Sfceiling);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1109 defsubr (&Sffloor);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1110 defsubr (&Sfround);
c77607f8e32d (FLOAT_CHECK_ERRNO): Define unless NO_FLOAT_CHECK_ERRNO.
Richard M. Stallman <rms@gnu.org>
parents: 1918
diff changeset
1111 defsubr (&Sftruncate);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1112 defsubr (&Sexp);
683
7f4d77d29804 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 638
diff changeset
1113 defsubr (&Sexpt);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1114 defsubr (&Slog);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1115 defsubr (&Slog10);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1116 defsubr (&Ssqrt);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1117
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1118 defsubr (&Sabs);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1119 defsubr (&Sfloat);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1120 defsubr (&Slogb);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1121 defsubr (&Sceiling);
16857
bdafa1f28a64 (rounding_driver): New function for systematic support of
Paul Eggert <eggert@twinsun.com>
parents: 16786
diff changeset
1122 defsubr (&Sfloor);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1123 defsubr (&Sround);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1124 defsubr (&Struncate);
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1125 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
1126
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
1127 /* arch-tag: be05bf9d-049e-4e31-91b9-e6153d483ae7
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
1128 (do not change this comment) */