X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/06d8ace51597cd41e110560a56a1abeb6cce23d6..a8d3cbf75d219d7a249fc0623219511179e959da:/src/floatfns.c diff --git a/src/floatfns.c b/src/floatfns.c index 2b26347cc1..305c78cae6 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -1,6 +1,7 @@ /* 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, 2011 Free Software Foundation, Inc. + +Copyright (C) 1988, 1993-1994, 1999, 2001-2012 + Free Software Foundation, Inc. Author: Wolfgang Rupprecht (according to ack.texi) @@ -52,10 +53,7 @@ along with GNU Emacs. If not, see . */ #include "lisp.h" #include "syssignal.h" -#if STDC_HEADERS #include -#endif - /* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ #ifndef IEEE_FLOATING_POINT #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ @@ -73,7 +71,7 @@ along with GNU Emacs. If not, see . */ extern double logb (double); #endif /* not HPUX and HAVE_LOGB and no logb macro */ -#if defined(DOMAIN) && defined(SING) && defined(OVERFLOW) +#if defined (DOMAIN) && defined (SING) && defined (OVERFLOW) /* If those are defined, then this is probably a `matherr' machine. */ # ifndef HAVE_MATHERR # define HAVE_MATHERR @@ -102,7 +100,7 @@ extern double logb (double); #endif #ifdef FLOAT_CATCH_SIGILL -static SIGTYPE float_error (); +static void float_error (); #endif /* Nonzero while executing in floating point. @@ -125,7 +123,7 @@ static const char *float_error_fn_name; 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 @@ -186,8 +184,10 @@ static const char *float_error_fn_name; 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. */ @@ -282,7 +282,9 @@ DEFUN ("tan", Ftan, Stan, 1, 1, 0, return make_float (d); } -#if defined HAVE_ISNAN && defined HAVE_COPYSIGN +#undef isnan +#define isnan(x) ((x) != (x)) + DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, doc: /* Return non nil iff argument X is a NaN. */) (Lisp_Object x) @@ -291,7 +293,8 @@ DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, return isnan (XFLOAT_DATA (x)) ? Qt : Qnil; } -DEFUN ("copysign", Fcopysign, Scopysign, 1, 2, 0, +#ifdef HAVE_COPYSIGN +DEFUN ("copysign", Fcopysign, Scopysign, 2, 2, 0, doc: /* Copy sign of X2 to value of X1, and return the result. Cause an error if X1 or X2 is not a float. */) (Lisp_Object x1, Lisp_Object x2) @@ -325,9 +328,9 @@ If X is zero, both parts (SGNFCAND and EXP) are zero. */) 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)); } } @@ -335,10 +338,10 @@ DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0, 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 @@ -504,7 +507,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, if (y & 1) acc *= x; x *= x; - y = (unsigned)y >> 1; + y >>= 1; } } XSETINT (val, acc); @@ -516,7 +519,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, if (f1 == 0.0 && f2 == 0.0) f1 = 1.0; #ifdef FLOAT_CHECK_DOMAIN - else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor(f2))) + else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor (f2))) domain_error2 ("expt", arg1, arg2); #endif IN_FLOAT2 (f3 = pow (f1, f2), "expt", arg1, arg2); @@ -957,9 +960,8 @@ Rounds the value toward zero. */) } #ifdef FLOAT_CATCH_SIGILL -static SIGTYPE -float_error (signo) - int signo; +static void +float_error (int signo) { if (! in_float) fatal_error_signal (signo); @@ -1031,12 +1033,12 @@ syms_of_floatfns (void) defsubr (&Scos); defsubr (&Ssin); defsubr (&Stan); -#if defined HAVE_ISNAN && defined HAVE_COPYSIGN defsubr (&Sisnan); +#ifdef HAVE_COPYSIGN defsubr (&Scopysign); defsubr (&Sfrexp); defsubr (&Sldexp); -#endif +#endif #if 0 defsubr (&Sacosh); defsubr (&Sasinh); @@ -1073,4 +1075,3 @@ syms_of_floatfns (void) defsubr (&Sround); defsubr (&Struncate); } -