From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toru TSUNEYOSHI Newsgroups: gmane.emacs.devel Subject: Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ? Date: Sat, 24 Oct 2009 20:59:47 +0900 Message-ID: References: <83y6n1gb14.fsf@gnu.org> <83vdi5f9gy.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1256385622 10685 80.91.229.12 (24 Oct 2009 12:00:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Oct 2009 12:00:22 +0000 (UTC) Cc: emacs-devel@gnu.org To: eliz@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 24 14:00:14 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N1fI5-0002hC-J9 for ged-emacs-devel@m.gmane.org; Sat, 24 Oct 2009 14:00:13 +0200 Original-Received: from localhost ([127.0.0.1]:48672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1fI4-0008V0-P7 for ged-emacs-devel@m.gmane.org; Sat, 24 Oct 2009 08:00:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1fHx-0008Tj-Dn for emacs-devel@gnu.org; Sat, 24 Oct 2009 08:00:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1fHs-0008PL-Uq for emacs-devel@gnu.org; Sat, 24 Oct 2009 08:00:04 -0400 Original-Received: from [199.232.76.173] (port=38919 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1fHs-0008PI-I1 for emacs-devel@gnu.org; Sat, 24 Oct 2009 08:00:00 -0400 Original-Received: from blu0-omc2-s27.blu0.hotmail.com ([65.55.111.102]:54992) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N1fHr-0001as-40; Sat, 24 Oct 2009 07:59:59 -0400 Original-Received: from BLU0-SMTP85 ([65.55.111.71]) by blu0-omc2-s27.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 24 Oct 2009 04:59:59 -0700 X-Originating-IP: [124.155.30.210] X-Originating-Email: [t_tuneyosi@hotmail.com] Original-Received: from localhost ([124.155.30.210]) by BLU0-SMTP85.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Sat, 24 Oct 2009 04:59:58 -0700 In-Reply-To: <83vdi5f9gy.fsf@gnu.org> X-Mailer: Mew version 6.2 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) X-OriginalArrivalTime: 24 Oct 2009 11:59:58.0295 (UTC) FILETIME=[821DF670:01CA54A1] X-detected-operating-system: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:116364 Archived-At: From: Eli Zaretskii > 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.