From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.devel Subject: Re: GMP code committed -- watch for bugs. Date: Sun, 06 Apr 2003 13:43:40 -0500 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87vfxrv543.fsf@raven.i.defaultvalue.org> References: <87he9dhoxh.fsf@raven.i.defaultvalue.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1049654858 9143 80.91.224.249 (6 Apr 2003 18:47:38 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 6 Apr 2003 18:47:38 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Apr 06 20:47:37 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 192FB3-0002NI-00 for ; Sun, 06 Apr 2003 20:47:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 192FAa-0002Nx-02 for guile-devel@m.gmane.org; Sun, 06 Apr 2003 14:47:08 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 192FA1-00022e-00 for guile-devel@gnu.org; Sun, 06 Apr 2003 14:46:33 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 192F9f-0001BF-00 for guile-devel@gnu.org; Sun, 06 Apr 2003 14:46:13 -0400 Original-Received: from dsl093-098-016.wdc1.dsl.speakeasy.net ([66.93.98.16] helo=defaultvalue.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 192F7H-0007Yg-00 for guile-devel@gnu.org; Sun, 06 Apr 2003 14:43:43 -0400 Original-Received: from raven.i.defaultvalue.org (raven.i.defaultvalue.org [192.168.1.7]) by defaultvalue.org (Postfix) with ESMTP id 8A26C13FB0; Sun, 6 Apr 2003 13:43:40 -0500 (CDT) Original-Received: by raven.i.defaultvalue.org (Postfix, from userid 1000) id 60859E5FDE; Sun, 6 Apr 2003 13:43:40 -0500 (CDT) Original-To: djurfeldt@nada.kth.se In-Reply-To: (Mikael Djurfeldt's message of "Sun, 06 Apr 2003 11:16:44 +0200") User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2134 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2134 Mikael Djurfeldt writes: > numbits = mpz_sizeinbase (SCM_I_BIG_MPZ (num), 2); > if (UNSIGNED) numbits++; > scm_remember_upto_here_1 (num); > if (numbits > (sizeof (ITYPE) * 8)) > scm_out_of_range (s_caller, num); > > Firstly, you probably intended to write "if (!UNSIGNED)" (to make room > for the sign bit). Indeed. > Secondly, that doesn't work either. For example, the absolute value > of LLONG_MIN requires 64 bits, even though it is a signed number. > So, regardless if we have "if (UNSIGNED)" or "if (!UNSIGNED)" there > will always be a case where a valid long_long or ulong_long will > cause an out_of_range error. Hmm. Actually it looks like mpz_sizeinbase includes the needed sign bit in its computation (for some reason I thought it didn't). So I don't think we need the numbits++ at all. -- Rob Browning rlb @defaultvalue.org, @linuxdevel.com, and @debian.org Previously @cs.utexas.edu GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel