summaryrefslogtreecommitdiff
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@redhat.com>1993-02-22 14:41:26 +0000
committerJim Blandy <jimb@redhat.com>1993-02-22 14:41:26 +0000
commitf8d830994a14d0247443b8f0e567c6f18aee5dbd (patch)
treef7b5444bfbc695f20e96e2ebe87cb8d7d9e1d4b0 /src/floatfns.c
parent0e95600962330eb5103ccdae94211f800346e1e2 (diff)
downloademacs-f8d830994a14d0247443b8f0e567c6f18aee5dbd.tar.gz
emacs-f8d830994a14d0247443b8f0e567c6f18aee5dbd.tar.bz2
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;
/* Evaluate the floating point expression D, recording NUM
as the original argument for error messages.
D is normally an assignment expression.
- Handle errors which may result in signals or may set errno. */
+ Handle errors which may result in signals or may set errno.
+
+ Note that float_error may be declared to return void, so you can't
+ just cast the zero after the colon to (SIGTYPE) to make the types
+ check properly. */
#define IN_FLOAT(D, NUM) \
(in_float = 1, errno = 0, float_error_arg = NUM, (D), \
- (errno == ERANGE || errno == EDOM ? float_error () : (SIGTYPE) 0), \
+ (errno == ERANGE || errno == EDOM ? (float_error (),0) : 0), \
in_float = 0)
/* 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.")
(num)
Lisp_Object num;
{
-#ifdef USG
- /* System V apparently doesn't have a `logb' function. */
+ /* System V apparently doesn't have a `logb' function. It might be
+ better to use it on systems that have it, but Ultrix (at least)
+ doesn't declare it properly in <math.h>; does anyone really care? */
return Flog (num, make_number (2));
-#else
- Lisp_Object val;
- double f = extract_float (num);
-
- IN_FLOAT (val = logb (f), num);
- XSET (val, Lisp_Int, val);
- return val;
-#endif
}
/* the rounding functions */
@@ -487,12 +484,14 @@ DEFUN ("round", Fround, Sround, 1, 1, 0,
if (XTYPE (num) == Lisp_Float)
{
-#ifdef USG
/* Screw the prevailing rounding mode. */
IN_FLOAT (XSET (num, Lisp_Int, floor (XFLOAT (num)->data + 0.5)), num);
-#else
- IN_FLOAT (XSET (num, Lisp_Int, rint (XFLOAT (num)->data)), num);
-#endif
+
+ /* It used to be that on non-USG systems we'd use the `rint'
+ function. But that seems not to be declared properly in
+ <math.h> on Ultrix, I don't want to declare it myself because
+ that might conflict with <math.h> on other systems, and I
+ don't see what's wrong with the code above anyway. */
}
return num;