aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorPaul Eggert2018-09-11 11:34:05 -0700
committerPaul Eggert2018-09-11 11:34:44 -0700
commit40a031e177459f9e7e393fae3766578eed41bedc (patch)
tree9f6c7ae72a7cc461df71789d79e8e8c77ecde649 /src/floatfns.c
parent038a09041af20ed373b15715fbc859d4a305dda8 (diff)
downloademacs-40a031e177459f9e7e393fae3766578eed41bedc.tar.gz
emacs-40a031e177459f9e7e393fae3766578eed41bedc.zip
Minor rounding_driver simplification
* src/floatfns.c (rounding_driver): Omit last arg, which is now unused. All callers changed. Signal overflow-error for bignum overflow
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 8e56fed9d09..6f5aee2db9d 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -339,8 +339,7 @@ static Lisp_Object
339rounding_driver (Lisp_Object arg, Lisp_Object divisor, 339rounding_driver (Lisp_Object arg, Lisp_Object divisor,
340 double (*double_round) (double), 340 double (*double_round) (double),
341 void (*int_divide) (mpz_t, mpz_t const, mpz_t const), 341 void (*int_divide) (mpz_t, mpz_t const, mpz_t const),
342 EMACS_INT (*fixnum_divide) (EMACS_INT, EMACS_INT), 342 EMACS_INT (*fixnum_divide) (EMACS_INT, EMACS_INT))
343 const char *name)
344{ 343{
345 CHECK_NUMBER (arg); 344 CHECK_NUMBER (arg);
346 345
@@ -474,7 +473,7 @@ This rounds the value towards +inf.
474With optional DIVISOR, return the smallest integer no less than ARG/DIVISOR. */) 473With optional DIVISOR, return the smallest integer no less than ARG/DIVISOR. */)
475 (Lisp_Object arg, Lisp_Object divisor) 474 (Lisp_Object arg, Lisp_Object divisor)
476{ 475{
477 return rounding_driver (arg, divisor, ceil, mpz_cdiv_q, ceiling2, "ceiling"); 476 return rounding_driver (arg, divisor, ceil, mpz_cdiv_q, ceiling2);
478} 477}
479 478
480DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0, 479DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0,
@@ -483,7 +482,7 @@ This rounds the value towards -inf.
483With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR. */) 482With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR. */)
484 (Lisp_Object arg, Lisp_Object divisor) 483 (Lisp_Object arg, Lisp_Object divisor)
485{ 484{
486 return rounding_driver (arg, divisor, floor, mpz_fdiv_q, floor2, "floor"); 485 return rounding_driver (arg, divisor, floor, mpz_fdiv_q, floor2);
487} 486}
488 487
489DEFUN ("round", Fround, Sround, 1, 2, 0, 488DEFUN ("round", Fround, Sround, 1, 2, 0,
@@ -496,8 +495,7 @@ your machine. For example, (round 2.5) can return 3 on some
496systems, but 2 on others. */) 495systems, but 2 on others. */)
497 (Lisp_Object arg, Lisp_Object divisor) 496 (Lisp_Object arg, Lisp_Object divisor)
498{ 497{
499 return rounding_driver (arg, divisor, emacs_rint, rounddiv_q, round2, 498 return rounding_driver (arg, divisor, emacs_rint, rounddiv_q, round2);
500 "round");
501} 499}
502 500
503/* Since rounding_driver truncates anyway, no need to call 'trunc'. */ 501/* Since rounding_driver truncates anyway, no need to call 'trunc'. */
@@ -513,8 +511,7 @@ Rounds ARG toward zero.
513With optional DIVISOR, truncate ARG/DIVISOR. */) 511With optional DIVISOR, truncate ARG/DIVISOR. */)
514 (Lisp_Object arg, Lisp_Object divisor) 512 (Lisp_Object arg, Lisp_Object divisor)
515{ 513{
516 return rounding_driver (arg, divisor, identity, mpz_tdiv_q, truncate2, 514 return rounding_driver (arg, divisor, identity, mpz_tdiv_q, truncate2);
517 "truncate");
518} 515}
519 516
520 517