X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/c2d4ea7421ca2fc572179704725ef83b8303aeb2..6bde8427201e9c8c034f2851f644524396321cfa:/src/floatfns.c diff --git a/src/floatfns.c b/src/floatfns.c index c0d052aaba..ca5b93755f 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -242,9 +242,7 @@ DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, return make_float (d); } -#endif - -DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, +DEFUN ("cbrt", Fcbrt, Scbrt, 1, 1, 0, "Return the cube root of ARG.") (num) register Lisp_Object num; @@ -254,6 +252,8 @@ DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, return make_float (d); } +#endif + DEFUN ("exp", Fexp, Sexp, 1, 1, 0, "Return the exponential base e of ARG.") (num) @@ -264,16 +264,6 @@ DEFUN ("exp", Fexp, Sexp, 1, 1, 0, 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 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, 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 @@ DEFUN ("log10", Flog10, Slog10, 1, 1, 0, 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) @@ -350,7 +339,7 @@ DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, return make_float (d); } -#ifndef /* Not clearly worth adding. */ +#if 0 /* Not clearly worth adding. */ DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, "Return the inverse hyperbolic cosine of ARG.") @@ -447,14 +436,17 @@ 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. */ + 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 @@ DEFUN ("round", Fround, Sround, 1, 1, 0, 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; } @@ -565,14 +564,12 @@ syms_of_floatfns () defsubr (&Serf); defsubr (&Serfc); defsubr (&Slog_gamma); + defsubr (&Scbrt); #endif - defsubr (&Scube_root); defsubr (&Sexp); - defsubr (&Sexpm1); defsubr (&Sexpt); defsubr (&Slog); defsubr (&Slog10); - defsubr (&Slog1p); defsubr (&Ssqrt); defsubr (&Sabs);