[FIX][Semantics][CORE] Integer>>highBit

Stephan Rudlof sr at evolgo.de
Fri Jun 9 04:30:30 UTC 2000


Dear Squeakers,

here is a changeset with a semantic change for LargeNegativeIntegers. It
also removes a division bug reported by Andreas Raab (see below).

"Change Set:		Fix-highBit-sr
Date:			8 June 2000
Author:			Stephan Rudlof

Fixes a bug originating from a mixture of two-complement and magnitude
arithmetics.
Introduces a differentiation between Integer>>highBit and
Integer>>highBitOfMagnitude.
Integer>>highBit has *always* two-complement semantics now, and
therefore it isn't defined for negative Integers.
Integer>>highBitOfMagnitude returns the number of the highest bit of the
magnitude (absolute value) of the receiver, therefore it is defined as
for positive as for negative Integers.


Motivation

Integer>>digitLshift: needs the high bit of the magnitude of the
receiver:
This has worked
- for LargeIntegers, because their >>highBit returned their magnitude
high bit, and also
- for positive SmallIntegers, because their two-complement high bit is
the same as their magnitude high bit,
- but *not* for *negative* SmallIntegers, because their two-complement
high bit is *not* defined!

So I have made a distinction between two-complement >>highBit and
magnitude >>highBitForMagnitude and changed calling methods accordingly.


Evaluation

Evaluate

	-585148196 // -1442692966

(taken from a bug report of Andreas Raab) before and after applying this
changeset, but without using the LargeIntegers module (!), to see the
effect of this changeset.


Note

The LargeIntegers module isn't affected by this problem, because it
converts SmallIntegers to LargeIntegers before performing arithmetics
(and uses highBit of magnitude)."


Greetings,

Stephan

P.S.: A solution for the right-shifting problem of LargeNegativeIntegers
is in the pipeline...

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fix-highBit-sr.1.cs
Type: application/octet-stream
Size: 9301 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000609/067db408/Fix-highBit-sr.1.obj


More information about the Squeak-dev mailing list