Bug in Integer?
Christopher Oliver
oliver at fritz.traverse.net
Tue Sep 8 18:00:13 UTC 1998
Pat Caudill pointed out that I might run into difficulties with the absol-
ute value of (SmallInteger minval) which is a LargePositiveInteger. Ok,
but in digging into SmallInteger>>quo: I find the following:
quo: aNumber
"Primitive. Divide the receiver by the argument and answer with the
result. Round the result down towards zero to make it a whole integer.
Fail if the argument is 0 or is not a SmallInteger. Optional. See Object
documentation whatIsAPrimitive."
<primitive: 13>
aNumber = 0 ifTrue: [^self error: 'Attempt to divide by zero'].
(aNumber isMemberOf: SmallInteger)
ifTrue: [self primitiveFailed]
ifFalse: [^super quo: aNumber]
Why should we simply fail if we know we have a numerator and denominator
which are of class SmallInteger? Doesn't this happen exclusively for
SmallInteger minval quo: -1 on any architecture we're considering? Since
we know this is SmallInteger maxval + 1, should we return this instead?
--
Christopher Oliver Traverse Internet
Systems Coordinator 223 Grandview Pkwy, Suite 108
oliver at traverse.net Traverse City, Michigan, 49684
"What good is a can of worms if you never open it?" -Bob Arning
More information about the Squeak-dev
mailing list
|