unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Rob Browning <rlb@defaultvalue.org>
Cc: guile-devel@gnu.org
Subject: Re: GMP code committed -- watch for bugs.
Date: Sun, 06 Apr 2003 13:43:40 -0500	[thread overview]
Message-ID: <87vfxrv543.fsf@raven.i.defaultvalue.org> (raw)
In-Reply-To: <xy7of3kkmtf.fsf@nada.kth.se> (Mikael Djurfeldt's message of "Sun, 06 Apr 2003 11:16:44 +0200")

Mikael Djurfeldt <djurfeldt@nada.kth.se> 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


  reply	other threads:[~2003-04-06 18:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-04 22:34 GMP code committed -- watch for bugs Rob Browning
2003-04-05 12:24 ` Marius Vollmer
2003-04-05 21:51 ` Mikael Djurfeldt
2003-04-05 22:26   ` Rob Browning
2003-04-06  7:41     ` Mikael Djurfeldt
2003-04-06  9:16   ` Mikael Djurfeldt
2003-04-06 18:43     ` Rob Browning [this message]
2003-04-06 19:12       ` Mikael Djurfeldt
2003-04-06 20:09         ` Rob Browning
2003-04-06 20:25     ` Rob Browning
2003-04-06  9:23 ` Mikael Djurfeldt
2003-04-06 20:15   ` Rob Browning
2003-04-06 22:50 ` Kevin Ryde
2003-05-10  0:22   ` GMP code committed -- watch for bugs ... gcd n 0 Kevin Ryde
2003-04-23 22:40 ` GMP code committed -- watch for bugs Kevin Ryde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vfxrv543.fsf@raven.i.defaultvalue.org \
    --to=rlb@defaultvalue.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).