aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorStephen Berman2013-06-14 22:07:55 +0200
committerStephen Berman2013-06-14 22:07:55 +0200
commitbd358779861f265a7acff31ead40172735af693e (patch)
tree345217a9889dbd29b09bdc80a94265c17719d41f /src/floatfns.c
parent2a97b47f0878cbda86cb6ba0e7e744924810b70e (diff)
parentf7394b12358ae453a0c8b85fc307afc1b740010d (diff)
downloademacs-bd358779861f265a7acff31ead40172735af693e.tar.gz
emacs-bd358779861f265a7acff31ead40172735af693e.zip
Merge from trunk.
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 66d7ca4af2c..6113758f964 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -1,7 +1,7 @@
1/* Primitive operations on floating point for GNU Emacs Lisp interpreter. 1/* Primitive operations on floating point for GNU Emacs Lisp interpreter.
2 2
3Copyright (C) 1988, 1993-1994, 1999, 2001-2012 3Copyright (C) 1988, 1993-1994, 1999, 2001-2013 Free Software Foundation,
4 Free Software Foundation, Inc. 4Inc.
5 5
6Author: Wolfgang Rupprecht 6Author: Wolfgang Rupprecht
7(according to ack.texi) 7(according to ack.texi)
@@ -29,17 +29,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 */ 29 */
30 30
31#include <config.h> 31#include <config.h>
32#include <setjmp.h>
33#include "lisp.h"
34#include "syssignal.h"
35 32
36#include <float.h> 33#include "lisp.h"
37#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
38 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
39#define IEEE_FLOATING_POINT 1
40#else
41#define IEEE_FLOATING_POINT 0
42#endif
43 34
44#include <math.h> 35#include <math.h>
45 36
@@ -202,7 +193,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
202 CHECK_NUMBER_OR_FLOAT (arg2); 193 CHECK_NUMBER_OR_FLOAT (arg2);
203 if (INTEGERP (arg1) /* common lisp spec */ 194 if (INTEGERP (arg1) /* common lisp spec */
204 && INTEGERP (arg2) /* don't promote, if both are ints, and */ 195 && INTEGERP (arg2) /* don't promote, if both are ints, and */
205 && 0 <= XINT (arg2)) /* we are sure the result is not fractional */ 196 && XINT (arg2) >= 0) /* we are sure the result is not fractional */
206 { /* this can be improved by pre-calculating */ 197 { /* this can be improved by pre-calculating */
207 EMACS_INT y; /* some binary powers of x then accumulating */ 198 EMACS_INT y; /* some binary powers of x then accumulating */
208 EMACS_UINT acc, x; /* Unsigned so that overflow is well defined. */ 199 EMACS_UINT acc, x; /* Unsigned so that overflow is well defined. */
@@ -408,8 +399,8 @@ round2 (EMACS_INT i1, EMACS_INT i2)
408 odd. */ 399 odd. */
409 EMACS_INT q = i1 / i2; 400 EMACS_INT q = i1 / i2;
410 EMACS_INT r = i1 % i2; 401 EMACS_INT r = i1 % i2;
411 EMACS_INT abs_r = r < 0 ? -r : r; 402 EMACS_INT abs_r = eabs (r);
412 EMACS_INT abs_r1 = (i2 < 0 ? -i2 : i2) - abs_r; 403 EMACS_INT abs_r1 = eabs (i2) - abs_r;
413 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1); 404 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1);
414} 405}
415 406
@@ -484,7 +475,7 @@ fmod_float (Lisp_Object x, Lisp_Object y)
484 f1 = fmod (f1, f2); 475 f1 = fmod (f1, f2);
485 476
486 /* If the "remainder" comes out with the wrong sign, fix it. */ 477 /* If the "remainder" comes out with the wrong sign, fix it. */
487 if (f2 < 0 ? 0 < f1 : f1 < 0) 478 if (f2 < 0 ? f1 > 0 : f1 < 0)
488 f1 += f2; 479 f1 += f2;
489 480
490 return make_float (f1); 481 return make_float (f1);