bug-gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lshift bug


From: Anton Ertl
Subject: Re: lshift bug
Date: Sun, 17 May 2020 18:10:18 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Sun, May 17, 2020 at 05:52:29PM +0200, Klaus Schleisiek wrote:
> Am 16.05.2020 um 18:06 schrieb Anton Ertl:
> > In Gforth, LSHIFT does what unsigned << does in gcc (it's undefined in
> > C, and AFAIK GNU C does not define it, either), which is typically
> > what the hardware does.  On a lot of hardware, for 64-bit shifts only
> > the low-order 6 bits are passed to the shifter (i.e., shift by 64 is
> > equivalent to shift by 0).
> 
> Aber wenn C es mathematisch inkorrekt macht und etliche Vendors das 
> nachgemacht
> haben, so dass der Fall nicht standardisiert werden konnte, dann könnte gforth
> es ja wenigstens korrekt machen. Oder bricht dadurch zu viel Code?

Unlikely.

> Jedenfalls ist mein Code gebrochen, als ich : 2**  1 swap lshift ; definiert
> habe statt vorher : 2**  1 swap 0 ?DO 2* LOOP ;
> 
> Aber so, wie der Standard jetzt ist, bleibt mir nix anderes übrig.

You can also define:

: 2** 1 over lshift swap 8 cells < and ;

and this should work as you expect.  But I would not call a result 0
"mathematically correct".

- anton



reply via email to

[Prev in Thread] Current Thread [Next in Thread]