[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?
From: |
Toru TSUNEYOSHI |
Subject: |
Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ? |
Date: |
Sat, 24 Oct 2009 20:59:47 +0900 |
From: Eli Zaretskii <address@hidden>
> No. The cast inside make_fixnum_or_float is to EMACS_INT, not to
> `int'.
Sorry, I misunderstood. :<
> On 64-bit platforms, EMACS_INT is a 64-bit type, so casting a
> `double' to EMACS_INT does not lose any precision. Casting an
> EMACS_INT to a `double' will cause loss of significant digits in the
> EMACS_INT value.
OK.
BTW, how does Emacs on 64-bit platforms eval the following expressions?
(string-to-number "1152921504606846975") ; 2^60 - 1
=> 1.1529215046068467e+018 ; on 32-bit platforms
On 64-bit platforms, string-to-number should return the number as type
`EMACS_INT' (= `LONG'), I think.
Although, the code of string-to-number (Fstring_to_number) deals with
the number as type `double' (of variable `v').
So type `double' can't properly deal with (1st, 2nd, and 3rd) least
significant digits of the number, I think.
#define make_fixnum_or_float(val) \
(FIXNUM_OVERFLOW_P (val) \
? make_float (val) \
: make_number ((EMACS_INT)(val)))
In this code, FIXNUM_OVERFLOW_P (val) will returns 0.
Then Emacs processes `make_number ((EMACS_INT)(val)))'.
On that time, `val' is casted from type `double' to `EMACS_INT'.
At last, can string-to-number return all digits of the number
1152921504606846975 properly?
I guessed it can't.
That is the reason why I made my former patch.
Message not available
Message not available
Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?, Andreas Schwab, 2009/10/23