/* Primitive operations on floating point for GNU Emacs Lisp interpreter.
- Copyright (C) 1988, 1993, 1994, 1999, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1988, 1993-1994, 1999, 2001-2011
+ Free Software Foundation, Inc.
Author: Wolfgang Rupprecht
(according to ack.texi)
#endif
#ifdef FLOAT_CATCH_SIGILL
-static SIGTYPE float_error ();
+static void float_error ();
#endif
/* Nonzero while executing in floating point.
static Lisp_Object float_error_arg, float_error_arg2;
-static char *float_error_fn_name;
+static const char *float_error_fn_name;
/* Evaluate the floating point expression D, recording NUM
as the original argument for error messages.
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
+ just cast the zero after the colon to (void) to make the types
check properly. */
#ifdef FLOAT_CHECK_ERRNO
xsignal3 (Qrange_error, build_string ((op)), (a1), (a2))
#define domain_error(op,arg) \
xsignal2 (Qdomain_error, build_string ((op)), (arg))
+#ifdef FLOAT_CHECK_DOMAIN
#define domain_error2(op,a1,a2) \
xsignal3 (Qdomain_error, build_string ((op)), (a1), (a2))
+#endif
/* Extract a Lisp number as a `double', or signal an error. */
double
-extract_float (num)
- Lisp_Object num;
+extract_float (Lisp_Object num)
{
CHECK_NUMBER_OR_FLOAT (num);
return Fcons (make_float (0.0), make_number (0));
else
{
- int exp;
- double sgnfcand = frexp (f, &exp);
- return Fcons (make_float (sgnfcand), make_number (exp));
+ int exponent;
+ double sgnfcand = frexp (f, &exponent);
+ return Fcons (make_float (sgnfcand), make_number (exponent));
}
}
doc: /* Construct number X from significand SGNFCAND and exponent EXP.
Returns the floating point value resulting from multiplying SGNFCAND
(the significand) by 2 raised to the power of EXP (the exponent). */)
- (Lisp_Object sgnfcand, Lisp_Object exp)
+ (Lisp_Object sgnfcand, Lisp_Object exponent)
{
- CHECK_NUMBER (exp);
- return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exp)));
+ CHECK_NUMBER (exponent);
+ return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exponent)));
}
#endif
\f
return arg;
}
-DEFUN ("float", Ffloat, Sfloat, 1, 1, 0,
+DEFUE ("float", Ffloat, Sfloat, 1, 1, 0,
doc: /* Return the floating point number equal to ARG. */)
(register Lisp_Object arg)
{
rounding_driver (Lisp_Object arg, Lisp_Object divisor,
double (*double_round) (double),
EMACS_INT (*int_round2) (EMACS_INT, EMACS_INT),
- char *name)
+ const char *name)
{
CHECK_NUMBER_OR_FLOAT (arg);
return rounding_driver (arg, divisor, emacs_rint, round2, "round");
}
-DEFUN ("truncate", Ftruncate, Struncate, 1, 2, 0,
+DEFUE ("truncate", Ftruncate, Struncate, 1, 2, 0,
doc: /* Truncate a floating point number to an int.
Rounds ARG toward zero.
With optional DIVISOR, truncate ARG/DIVISOR. */)
}
\f
#ifdef FLOAT_CATCH_SIGILL
-static SIGTYPE
+static void
float_error (signo)
int signo;
{
#ifdef HAVE_MATHERR
int
-matherr (x)
- struct exception *x;
+matherr (struct exception *x)
{
Lisp_Object args;
+ const char *name = x->name;
+
if (! in_float)
/* Not called from emacs-lisp float routines; do the default thing. */
return 0;
if (!strcmp (x->name, "pow"))
- x->name = "expt";
+ name = "expt";
args
- = Fcons (build_string (x->name),
+ = Fcons (build_string (name),
Fcons (make_float (x->arg1),
- ((!strcmp (x->name, "log") || !strcmp (x->name, "pow"))
+ ((!strcmp (name, "log") || !strcmp (name, "pow"))
? Fcons (make_float (x->arg2), Qnil)
: Qnil)));
switch (x->type)
#endif /* HAVE_MATHERR */
void
-init_floatfns ()
+init_floatfns (void)
{
#ifdef FLOAT_CATCH_SIGILL
signal (SIGILL, float_error);
}
void
-syms_of_floatfns ()
+syms_of_floatfns (void)
{
defsubr (&Sacos);
defsubr (&Sasin);
defsubr (&Scopysign);
defsubr (&Sfrexp);
defsubr (&Sldexp);
-#endif
+#endif
#if 0
defsubr (&Sacosh);
defsubr (&Sasinh);
defsubr (&Sround);
defsubr (&Struncate);
}
-
-/* arch-tag: be05bf9d-049e-4e31-91b9-e6153d483ae7
- (do not change this comment) */