GNU bug report logs - #32463
27.0.50; (logior -1) => 4611686018427387903

Previous Next

Package: emacs;

Reported by: Katsumi Yamaoka <yamaoka <at> jpl.org>

Date: Fri, 17 Aug 2018 03:31:02 UTC

Severity: normal

Found in version 27.0.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: 32463 <at> debbugs.gnu.org
Subject: bug#32463: 27.0.50; (logior -1) => 4611686018427387903
Date: Fri, 17 Aug 2018 14:24:02 +0100
On Fri 17 Aug 2018, Pip Cet wrote:

> On Fri, Aug 17, 2018 at 9:34 AM Andy Moreton <andrewjmoreton <at> gmail.com> wrote:
> Paul committed a patch in the meantime (independently, I think?) which
> does add tests. I'll try to write some more.

Thanks. I should have done that with my patches to fix some bignum bugs.

>> The tdiv/fdiv were
>> added to give expected results. Pay particular attention to values around
>> most-positive-fixnum and most-negative-fixnum.
>
> I don't think they do give the expected results. We should discuss
> that in more detail, but first, can we agree that lsh and ash behave
> the same for bignums? If so, clearly one branch of the code you quoted
> is incorrect, and I think it's the tdiv one.

I agree that for bignums lsh and ash should behave the same way. I can
easily belive that there are bugs in this code, as I was fighting
problems with 64bit Windows having 32bit long at the same time.

> I ran:
>
> (require 'cl)
>
> (let ((i 0))
>   (while (< i 128)
>     (message "%d %x" i (lsh (- (lsh -1 i) 1) -1))
>     (incf i)))

Or equivalently:
  (dotimes (i 128) (message "%d %x" i (lsh (1- (lsh -1 i)) -1)))

> and got this output:
>
> [...]
> 57 -100000000000001
> 58 -200000000000001
> 59 -400000000000001
> 60 -800000000000001
> 61 -1000000000000000
> 62 -2000000000000000
> 63 -4000000000000000
> 64 -8000000000000000
> [...]
>
> Something is wrong there.

Yes, this is clearly not behaving correctly and needs to be fixed.
Thanks for investigating this.

    AndyM





This bug report was last modified 6 years and 320 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.