Commit 23eab9a6 authored by Tom Tromey's avatar Tom Tromey
Browse files

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.
parent 6d4bf2ce
......@@ -2756,6 +2756,14 @@ NUMBER may be an integer or a floating point number. */)
int len;
if (BIGNUMP (number))
ptrdiff_t count = SPECPDL_INDEX ();
char *str = mpz_get_str (NULL, 10, XBIGNUM (number)->value);
record_unwind_protect_ptr (xfree, str);
return unbind_to (count, make_unibyte_string (str, strlen (str)));
if (FLOATP (number))
......@@ -574,4 +574,9 @@ comparing the subr with a much slower lisp implementation."
(should-not (fixnump (+ most-positive-fixnum 1)))
(should (bignump (+ most-positive-fixnum 1))))
(ert-deftest data-tests-number-to-string ()
(let* ((s "99999999999999999999999999999")
(v (read s)))
(should (equal (number-to-string v) s))))
;;; data-tests.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment