Mercurial > emacs
changeset 1005:70ed307d9047
* floatfns.c (Fexpm1, Flog1p): Function removed; it's not widely
available, and hardly vital.
(syms_of_floatfns): Adjusted appropriately.
* floatfns.c (Flog): Accept optional second arg, being the base
for the logarithm.
[USG] (Flogb): Define this in terms of Flog.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 19 Aug 1992 06:26:13 +0000 |
parents | 5318f9b7e442 |
children | a13ee72d74a2 |
files | src/floatfns.c |
diffstat | 1 files changed, 27 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/src/floatfns.c Wed Aug 19 06:25:25 1992 +0000 +++ b/src/floatfns.c Wed Aug 19 06:26:13 1992 +0000 @@ -264,16 +264,6 @@ return make_float (d); } -DEFUN ("expm1", Fexpm1, Sexpm1, 1, 1, 0, - "Return the exp (x)-1 of ARG.") - (num) - register Lisp_Object num; -{ - double d = extract_float (num); - IN_FLOAT (d = expm1 (d), num); - return make_float (d); -} - DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, "Return the exponential X ** Y.") (num1, num2) @@ -310,13 +300,22 @@ return make_float (f1); } -DEFUN ("log", Flog, Slog, 1, 1, 0, - "Return the natural logarithm of ARG.") - (num) +DEFUN ("log", Flog, Slog, 1, 2, 0, + "Return the natural logarithm of NUM. +If second optional argument BASE is given, return log NUM using that base.") + (num, base) register Lisp_Object num; { double d = extract_float (num); - IN_FLOAT (d = log (d), num); + + if (NILP (base)) + IN_FLOAT (d = log (d), num); + else + { + double b = extract_float (base); + + IN_FLOAT (d = log (num) / log (b), num); + } return make_float (d); } @@ -330,16 +329,6 @@ return make_float (d); } -DEFUN ("log1p", Flog1p, Slog1p, 1, 1, 0, - "Return the log (1+x) of ARG.") - (num) - register Lisp_Object num; -{ - double d = extract_float (num); - IN_FLOAT (d = log1p (d), num); - return make_float (d); -} - DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, "Return the square root of ARG.") (num) @@ -447,14 +436,17 @@ (num) Lisp_Object num; { +#ifdef USG + /* System V apparently doesn't have a `logb' function. */ + return Flog (num, make_number (2)); +#else Lisp_Object val; - double f; + double f = extract_float (num); - CHECK_NUMBER_OR_FLOAT (num, 0); - f = (XTYPE (num) == Lisp_Float) ? XFLOAT (num)->data : XINT (num); IN_FLOAT (val = logb (f), num); XSET (val, Lisp_Int, val); return val; +#endif } /* the rounding functions */ @@ -493,7 +485,14 @@ CHECK_NUMBER_OR_FLOAT (num, 0); if (XTYPE (num) == Lisp_Float) - IN_FLOAT (XSET (num, Lisp_Int, rint (XFLOAT (num)->data)), num); + { +#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 + } return num; } @@ -568,11 +567,9 @@ defsubr (&Scbrt); #endif defsubr (&Sexp); - defsubr (&Sexpm1); defsubr (&Sexpt); defsubr (&Slog); defsubr (&Slog10); - defsubr (&Slog1p); defsubr (&Ssqrt); defsubr (&Sabs);