diff options
| author | Paul Eggert | 2018-08-22 19:30:24 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-22 19:30:57 -0700 |
| commit | ee641b87cf220250ba89f219fb47a4406a05deb7 (patch) | |
| tree | 08ff44c5197ae39b2ec0906de4bb4dcafda4677f /src/alloc.c | |
| parent | be5fe6183e95f3afe3a62ec43504b99df90bc794 (diff) | |
| download | emacs-ee641b87cf220250ba89f219fb47a4406a05deb7.tar.gz emacs-ee641b87cf220250ba89f219fb47a4406a05deb7.zip | |
Fix bugs when rounding to bignums
Also, since Emacs historically reported a range error when
rounding operations overflowed, do that consistently for all
bignum overflows.
* doc/lispref/errors.texi (Standard Errors):
* doc/lispref/numbers.texi (Integer Basics): Document range errors.
* src/alloc.c (range_error): Rename from integer_overflow.
All uses changed.
* src/floatfns.c (rounding_driver): When the result of a floating
point rounding operation does not fit into a fixnum, put it
into a bignum instead of always signaling an range error.
* test/src/floatfns-tests.el (divide-extreme-sign):
These tests now return the mathematically-correct answer
instead of signaling an error.
(bignum-round): Check that integers round to themselves.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c index 24a24aab96b..cdcd465ac5a 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3771,7 +3771,7 @@ make_number (mpz_t value) | |||
| 3771 | /* The documentation says integer-width should be nonnegative, so | 3771 | /* The documentation says integer-width should be nonnegative, so |
| 3772 | a single comparison suffices even though 'bits' is unsigned. */ | 3772 | a single comparison suffices even though 'bits' is unsigned. */ |
| 3773 | if (integer_width < bits) | 3773 | if (integer_width < bits) |
| 3774 | integer_overflow (); | 3774 | range_error (); |
| 3775 | 3775 | ||
| 3776 | struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value, | 3776 | struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value, |
| 3777 | PVEC_BIGNUM); | 3777 | PVEC_BIGNUM); |
| @@ -7203,9 +7203,9 @@ verify_alloca (void) | |||
| 7203 | /* Memory allocation for GMP. */ | 7203 | /* Memory allocation for GMP. */ |
| 7204 | 7204 | ||
| 7205 | void | 7205 | void |
| 7206 | integer_overflow (void) | 7206 | range_error (void) |
| 7207 | { | 7207 | { |
| 7208 | error ("Integer too large to be represented"); | 7208 | xsignal0 (Qrange_error); |
| 7209 | } | 7209 | } |
| 7210 | 7210 | ||
| 7211 | static void * | 7211 | static void * |