aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Tromey2018-07-05 11:45:21 -0600
committerTom Tromey2018-07-12 22:12:27 -0600
commit23eab9a6a67604b5ebcdc99efc42fbfd3345c0b0 (patch)
tree43e91de269443be121e81e69e476e46ae32089b7 /src
parent6d4bf2cedab365411f0aedb373b63291086658e9 (diff)
downloademacs-23eab9a6a67604b5ebcdc99efc42fbfd3345c0b0.tar.gz
emacs-23eab9a6a67604b5ebcdc99efc42fbfd3345c0b0.zip
Make number-to-string work for bignums
* src/data.c (Fnumber_to_string): Handle bignum. * test/src/data-tests.el (data-tests-number-to-string): New test.
Diffstat (limited to 'src')
-rw-r--r--src/data.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/data.c b/src/data.c
index b49daabe85d..18b572de977 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2756,6 +2756,14 @@ NUMBER may be an integer or a floating point number. */)
2756 char buffer[max (FLOAT_TO_STRING_BUFSIZE, INT_BUFSIZE_BOUND (EMACS_INT))]; 2756 char buffer[max (FLOAT_TO_STRING_BUFSIZE, INT_BUFSIZE_BOUND (EMACS_INT))];
2757 int len; 2757 int len;
2758 2758
2759 if (BIGNUMP (number))
2760 {
2761 ptrdiff_t count = SPECPDL_INDEX ();
2762 char *str = mpz_get_str (NULL, 10, XBIGNUM (number)->value);
2763 record_unwind_protect_ptr (xfree, str);
2764 return unbind_to (count, make_unibyte_string (str, strlen (str)));
2765 }
2766
2759 CHECK_FIXNUM_OR_FLOAT (number); 2767 CHECK_FIXNUM_OR_FLOAT (number);
2760 2768
2761 if (FLOATP (number)) 2769 if (FLOATP (number))