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

Comment on HAULONG

What do people think of the following suggested change?  I suspect
MacLISP HAULONG was defined as it was because internally it used
sign-magnitude representation.  EAK's suggestion is more appropriate
for two's-complement, and the LOGxxx functions implicitly assume
that as a model.

- - - - Begin forwarded message - - - -
Mail-From: ARPANET host MIT-Multics received by CMU-10A at 7-Jul-82 17:03:29-EDT
Date: Wed, 07 Jul 1982 17:52:00 -0000
From:     Earl A. Killian            <Killian at MIT-MULTICS>
Subject:  haulong
To:       Guy Steele at CMUa

I think the definition in the manual for haulong:


is poor.  Better would be

if integer < 0 then ceiling(log2(-integer)) else ceiling(log2(integer+1))

I know of no non-conditional expression for this haulong (if you should
ever discover one, please let me know).  The only numbers that this
matters for are -2^N.  Amusingly enough, I found this exact bug in the two
compilers I've worked on (i.e. they thought it took 9 bits instead of 8
to store a -256..255).
- - - - End forwarded message - - - -