aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorJim Blandy1993-02-22 14:41:26 +0000
committerJim Blandy1993-02-22 14:41:26 +0000
commitf8d830994a14d0247443b8f0e567c6f18aee5dbd (patch)
treef7b5444bfbc695f20e96e2ebe87cb8d7d9e1d4b0 /src/floatfns.c
parent0e95600962330eb5103ccdae94211f800346e1e2 (diff)
downloademacs-f8d830994a14d0247443b8f0e567c6f18aee5dbd.tar.gz
emacs-f8d830994a14d0247443b8f0e567c6f18aee5dbd.zip
* floatfns.c (Flogb): Always implement this by calling Flog, even
on non-USG systems, which supposedly have a logb function. (Fround): Always implement this by calling floor, even on systems that have rint. * floatfns.c (IN_FLOAT): Make this work properly when SIGTYPE is void.
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index f0bff86a682..7968d1207d7 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -58,11 +58,15 @@ static Lisp_Object float_error_arg;
58/* Evaluate the floating point expression D, recording NUM 58/* Evaluate the floating point expression D, recording NUM
59 as the original argument for error messages. 59 as the original argument for error messages.
60 D is normally an assignment expression. 60 D is normally an assignment expression.
61 Handle errors which may result in signals or may set errno. */ 61 Handle errors which may result in signals or may set errno.
62
63 Note that float_error may be declared to return void, so you can't
64 just cast the zero after the colon to (SIGTYPE) to make the types
65 check properly. */
62 66
63#define IN_FLOAT(D, NUM) \ 67#define IN_FLOAT(D, NUM) \
64(in_float = 1, errno = 0, float_error_arg = NUM, (D), \ 68(in_float = 1, errno = 0, float_error_arg = NUM, (D), \
65 (errno == ERANGE || errno == EDOM ? float_error () : (SIGTYPE) 0), \ 69 (errno == ERANGE || errno == EDOM ? (float_error (),0) : 0), \
66 in_float = 0) 70 in_float = 0)
67 71
68/* Extract a Lisp number as a `double', or signal an error. */ 72/* Extract a Lisp number as a `double', or signal an error. */
@@ -437,17 +441,10 @@ This is the same as the exponent of a float.")
437 (num) 441 (num)
438Lisp_Object num; 442Lisp_Object num;
439{ 443{
440#ifdef USG 444 /* System V apparently doesn't have a `logb' function. It might be
441 /* System V apparently doesn't have a `logb' function. */ 445 better to use it on systems that have it, but Ultrix (at least)
446 doesn't declare it properly in <math.h>; does anyone really care? */
442 return Flog (num, make_number (2)); 447 return Flog (num, make_number (2));
443#else
444 Lisp_Object val;
445 double f = extract_float (num);
446
447 IN_FLOAT (val = logb (f), num);
448 XSET (val, Lisp_Int, val);
449 return val;
450#endif
451} 448}
452 449
453/* the rounding functions */ 450/* the rounding functions */
@@ -487,12 +484,14 @@ DEFUN ("round", Fround, Sround, 1, 1, 0,
487 484
488 if (XTYPE (num) == Lisp_Float) 485 if (XTYPE (num) == Lisp_Float)
489 { 486 {
490#ifdef USG
491 /* Screw the prevailing rounding mode. */ 487 /* Screw the prevailing rounding mode. */
492 IN_FLOAT (XSET (num, Lisp_Int, floor (XFLOAT (num)->data + 0.5)), num); 488 IN_FLOAT (XSET (num, Lisp_Int, floor (XFLOAT (num)->data + 0.5)), num);
493#else 489
494 IN_FLOAT (XSET (num, Lisp_Int, rint (XFLOAT (num)->data)), num); 490 /* It used to be that on non-USG systems we'd use the `rint'
495#endif 491 function. But that seems not to be declared properly in
492 <math.h> on Ultrix, I don't want to declare it myself because
493 that might conflict with <math.h> on other systems, and I
494 don't see what's wrong with the code above anyway. */
496 } 495 }
497 496
498 return num; 497 return num;