[Top][All Lists]

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

[Axiom-developer] Left shifts of negative numbers

From: Dylan Thurston
Subject: [Axiom-developer] Left shifts of negative numbers
Date: Tue, 14 Oct 2003 17:41:16 -0400
User-agent: Mutt/1.5.4i

I have investigated Bug #4733 (rounding of negative numbers).  The
problem is unexpected behaviour of 'shift' with negative arguments:
'shift(-7,-1)' is -4, while the code in the 'truncate' function in
float.spad.pamphlet clearly expects the answer to be -3 in this case.
The definition of what 'shift' should do in IntegerNumberSystem is
ambiguous about what should happen with negative arguments, but in
integer.spad.pamphlet 'shift' is actually implemented with a call to the
lisp function 'ash'; according to the standard I found on the web (see, 'ash'
should have the opposite behaviour: '(ash -7 -1)' should be -4 (as GCL

Presumably the correct fix involves changing 'shift' so that it rounds
towards 0 when both arguments are negative (and documenting how it
actually behaves), rather than changing the code in float.spad to deal
with the current behaviour?  What will other axiom code expect?  Most of
the instances in the algebra tree seem to apply 'shift' only when the
first argument is positive.


Attachment: signature.asc
Description: Digital signature

reply via email to

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