diff options
| author | Tom Tromey | 2018-07-05 13:17:36 -0600 |
|---|---|---|
| committer | Tom Tromey | 2018-07-12 22:12:27 -0600 |
| commit | 872faabbd8cb0f5518777b2d4fe7de187f684a92 (patch) | |
| tree | b09cc3fa24e232c156f7991008d080fd5c77d860 /src/floatfns.c | |
| parent | d14808cd271abf6a723bf495a6a01c14d18b5893 (diff) | |
| download | emacs-872faabbd8cb0f5518777b2d4fe7de187f684a92.tar.gz emacs-872faabbd8cb0f5518777b2d4fe7de187f684a92.zip | |
Allow conversion of bignums to floats
* src/floatfns.c (extract_float, Ffloat): Handle bignums.
* src/lisp.h (XFLOATINT): Handle bignums.
* test/src/floatfns-tests.el (bignum-to-float): New test.
Diffstat (limited to 'src/floatfns.c')
| -rw-r--r-- | src/floatfns.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/floatfns.c b/src/floatfns.c index 766044ba35c..bd3f2dec80a 100644 --- a/src/floatfns.c +++ b/src/floatfns.c | |||
| @@ -67,7 +67,7 @@ CHECK_FLOAT (Lisp_Object x) | |||
| 67 | double | 67 | double |
| 68 | extract_float (Lisp_Object num) | 68 | extract_float (Lisp_Object num) |
| 69 | { | 69 | { |
| 70 | CHECK_FIXNUM_OR_FLOAT (num); | 70 | CHECK_NUMBER (num); |
| 71 | return XFLOATINT (num); | 71 | return XFLOATINT (num); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| @@ -289,8 +289,10 @@ DEFUN ("float", Ffloat, Sfloat, 1, 1, 0, | |||
| 289 | doc: /* Return the floating point number equal to ARG. */) | 289 | doc: /* Return the floating point number equal to ARG. */) |
| 290 | (register Lisp_Object arg) | 290 | (register Lisp_Object arg) |
| 291 | { | 291 | { |
| 292 | CHECK_FIXNUM_OR_FLOAT (arg); | 292 | CHECK_NUMBER (arg); |
| 293 | 293 | ||
| 294 | if (BIGNUMP (arg)) | ||
| 295 | return make_float (mpz_get_d (XBIGNUM (arg)->value)); | ||
| 294 | if (FIXNUMP (arg)) | 296 | if (FIXNUMP (arg)) |
| 295 | return make_float ((double) XINT (arg)); | 297 | return make_float ((double) XINT (arg)); |
| 296 | else /* give 'em the same float back */ | 298 | else /* give 'em the same float back */ |