who ever performed bit logic on large negative integer?
ncellier at ifrance.com
Sat Jan 26 22:13:50 UTC 2008
Paolo Bonzini a écrit :
>>> It is possible to work out bitwise ops on magnitude representation,
>>> by computing the two's complement representation on the fly in the
>>> primitives or in the fallback Smalltalk code.
>> OK, another - better - way to go: should be much less work than
>> changing the representation.
> That's exactly what nicolas's patch in mantis does.
Oh, I did not that much!
All this arithmetic stuff simulating two complement was already there
for a long time in Squeak, bit logic was handled correctly in most cases.
My contribution is limited to finding a flaw in implementation in some
very rare conditions.
Thread title was a little provocation, because i think the feature is
rarely used, except accidentally. It was to eventually get an echo
proving me wrong.
In fact it is used very often via hash, since -3 hash = -3, and a lot of
bit logic is performed on hash codes, but:
1) a bug leading to a different hash would not matter
(as long as it does not lead systematically to a single hash code)
2) most hash should involve SmallInteger, not large ones.
Anyway, we cannot blame squeak for taking the hard path.
Some smalltalk dialects have costless solutions, kind of:
self error: 'cannot perform bit logic on negative integers'
More information about the Squeak-dev