🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.scheme.c
Article #44

Apparent bug with "*" for range 0xffc0-0xffff (R6.1.1)

#44
From: Guillermo J. Rozas
Date: Thu, 12 Oct 1989 18:28
30 lines
1427 bytes
       We have encountered an apparent bug in C-Scheme when attempting to
    multiply two values which are both in the range [65472..65535], which,
    for all you bit-twiddlers out there, is [0x0ffc0-0xffff]. A sample:

       1 ]=> (* 65535 65535)

       #[SEQUENCE -#x1FFFF]

The simplest patch is to modify procedure Mul (in microcode/mul.c) in
the following way:

replace the lines

  if (Lo_C > FIXNUM_SIGN_BIT)
    return NIL;

by

  if ((Lo_C > FIXNUM_SIGN_BIT) || (Lo_C < 0))
    return NIL;

The problem is that the various Hi and Lo have been declared as long,
rather than unsigned long, thus arithmetic is signed.  Declaring them
as unsigned should fix the problem too, but unfortunately some C
compilers ignore the unsigned declaration, and you might still have
a problem.  

I've only tried this patch on 68K HP machines, but it should work on
Suns and others.
Technical Details
Message-ID: <8910121828.AA06619@zurich.ai.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!bloom-beacon!ZURICH.AI.MIT.EDU!jinx
References: <8910121551.AA01295@bmc.its.rpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!bloom-beacon!ZURICH.AI.MIT.EDU!jinx
From: jinx@ZURICH.AI.MIT.EDU (Guillermo J. Rozas)
Newsgroups: comp.lang.scheme.c
Subject: Apparent bug with "*" for range 0xffc0-0xffff (R6.1.1)
Message-ID: <8910121828.AA06619@zurich.ai.mit.edu>
Date: 12 Oct 89 18:28:10 GMT
References: <8910121551.AA01295@bmc.its.rpi.edu>
Sender: daemon@bloom-beacon.MIT.EDU
Reply-To: jinx@zurich.ai.mit.edu
Distribution: inet
Organization: The Internet
Lines: 30