aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-08-19 06:26:13 +0000
committerJim Blandy1992-08-19 06:26:13 +0000
commit56abb480f7f866587fc62f7295c021e571757701 (patch)
tree18fe9309271d2c4f06a0574638d5e0f07a88ade4 /src
parentb0b97e8b3e789a8cbff859cb8f57554f0f361f5e (diff)
downloademacs-56abb480f7f866587fc62f7295c021e571757701.tar.gz
emacs-56abb480f7f866587fc62f7295c021e571757701.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/floatfns.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 07b8664c08c..ca5b93755f8 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -264,16 +264,6 @@ DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
264 return make_float (d); 264 return make_float (d);
265} 265}
266 266
267DEFUN ("expm1", Fexpm1, Sexpm1, 1, 1, 0,
268 "Return the exp (x)-1 of ARG.")
269 (num)
270 register Lisp_Object num;
271{
272 double d = extract_float (num);
273 IN_FLOAT (d = expm1 (d), num);
274 return make_float (d);
275}
276
277DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, 267DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
278 "Return the exponential X ** Y.") 268 "Return the exponential X ** Y.")
279 (num1, num2) 269 (num1, num2)
@@ -310,13 +300,22 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
310 return make_float (f1); 300 return make_float (f1);
311} 301}
312 302
313DEFUN ("log", Flog, Slog, 1, 1, 0, 303DEFUN ("log", Flog, Slog, 1, 2, 0,
314 "Return the natural logarithm of ARG.") 304 "Return the natural logarithm of NUM.
315 (num) 305If second optional argument BASE is given, return log NUM using that base.")
306 (num, base)
316 register Lisp_Object num; 307 register Lisp_Object num;
317{ 308{
318 double d = extract_float (num); 309 double d = extract_float (num);
319 IN_FLOAT (d = log (d), num); 310
311 if (NILP (base))
312 IN_FLOAT (d = log (d), num);
313 else
314 {
315 double b = extract_float (base);
316
317 IN_FLOAT (d = log (num) / log (b), num);
318 }
320 return make_float (d); 319 return make_float (d);
321} 320}
322 321
@@ -330,16 +329,6 @@ DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
330 return make_float (d); 329 return make_float (d);
331} 330}
332 331
333DEFUN ("log1p", Flog1p, Slog1p, 1, 1, 0,
334 "Return the log (1+x) of ARG.")
335 (num)
336 register Lisp_Object num;
337{
338 double d = extract_float (num);
339 IN_FLOAT (d = log1p (d), num);
340 return make_float (d);
341}
342
343DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, 332DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
344 "Return the square root of ARG.") 333 "Return the square root of ARG.")
345 (num) 334 (num)
@@ -447,14 +436,17 @@ This is the same as the exponent of a float.")
447 (num) 436 (num)
448Lisp_Object num; 437Lisp_Object num;
449{ 438{
439#ifdef USG
440 /* System V apparently doesn't have a `logb' function. */
441 return Flog (num, make_number (2));
442#else
450 Lisp_Object val; 443 Lisp_Object val;
451 double f; 444 double f = extract_float (num);
452 445
453 CHECK_NUMBER_OR_FLOAT (num, 0);
454 f = (XTYPE (num) == Lisp_Float) ? XFLOAT (num)->data : XINT (num);
455 IN_FLOAT (val = logb (f), num); 446 IN_FLOAT (val = logb (f), num);
456 XSET (val, Lisp_Int, val); 447 XSET (val, Lisp_Int, val);
457 return val; 448 return val;
449#endif
458} 450}
459 451
460/* the rounding functions */ 452/* the rounding functions */
@@ -493,7 +485,14 @@ DEFUN ("round", Fround, Sround, 1, 1, 0,
493 CHECK_NUMBER_OR_FLOAT (num, 0); 485 CHECK_NUMBER_OR_FLOAT (num, 0);
494 486
495 if (XTYPE (num) == Lisp_Float) 487 if (XTYPE (num) == Lisp_Float)
496 IN_FLOAT (XSET (num, Lisp_Int, rint (XFLOAT (num)->data)), num); 488 {
489#ifdef USG
490 /* Screw the prevailing rounding mode. */
491 IN_FLOAT (XSET (num, Lisp_Int, floor (XFLOAT (num)->data + 0.5)), num);
492#else
493 IN_FLOAT (XSET (num, Lisp_Int, rint (XFLOAT (num)->data)), num);
494#endif
495 }
497 496
498 return num; 497 return num;
499} 498}
@@ -568,11 +567,9 @@ syms_of_floatfns ()
568 defsubr (&Scbrt); 567 defsubr (&Scbrt);
569#endif 568#endif
570 defsubr (&Sexp); 569 defsubr (&Sexp);
571 defsubr (&Sexpm1);
572 defsubr (&Sexpt); 570 defsubr (&Sexpt);
573 defsubr (&Slog); 571 defsubr (&Slog);
574 defsubr (&Slog10); 572 defsubr (&Slog10);
575 defsubr (&Slog1p);
576 defsubr (&Ssqrt); 573 defsubr (&Ssqrt);
577 574
578 defsubr (&Sabs); 575 defsubr (&Sabs);