Squeak archeology - quo vs. //
Andreas Raab
andreas.raab at gmx.de
Tue Apr 6 12:40:19 UTC 2004
Hi Guys,
Today I got very subtly bitten by // truncating towards negative infinity
rather than zero, e.g.,
3//2 -> 1
-3//2 -> -2
whereas:
3 quo: 2 -> 1
-3 quo: 2 -> -1
The reason I got bitten is that the C translator generates // as C / which
has the semantics of #quo:. Meaning that any translated code which uses
integer divide with negative numbers will be subtly off.
My question here (and that's the historical part) how comes that // rounds
towards negative infinity?
Thanks for any enlightment,
- Andreas
More information about the Squeak-dev
mailing list
|