who ever performed bit logic on large negative integer?
Stephan Rudlof
sr at evolgo.de
Sat Jan 26 14:56:47 UTC 2008
There should be a comment somewhere (Integer class comment?) explicitly stating, that you cannot rely on two complement semantics for LargeNegativeIntegers regarding bit logic (bit logic restricted to positive Integers is correct).
I fear, changing the fundamental design decision to use magnitude representation for LargeNegativeIntegers - e.g. by introducing some kind of two complement representation - would imply a lot of work...
Regards,
Stephan
On 26.01.2008 04:12, nicolas cellier wrote:
>
> SmallInteger < 0 are stored directly in two complement native format
> (well, except the tag bits)
>
> But LargeNegativeInteger are stored same as their absolute value.
>
> This does simplify some algorithms. But this leads to quite tricky ones
> when bit logic is to be performed based on two complement.
> And whenever tricks are used, bugs frequency generally tends to
> increase. I believe long life bugs are lying in such swamps.
>
> That's why i'm very proud of finding accidentaly
> http://bugs.squeak.org/view.php?id=6874 via
> http://bugs.squeak.org/view.php?id=6873.
>
> As usual, most of you won't ever care of it.
> Yeah, one more useless bugfix i am specialized in since the probability
> you bump into it must not exceed 1.0e-8 per hour of Smalltalking.
>
> But who knows, it's a kind of insurance in case a silly engineer had the
> idea to run nearest nuclear plant in Squeak!
>
> And well, it's also for the beauty of mathematics!
>
> Nicolas
>
>
>
--
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
More information about the Squeak-dev
mailing list
|