Integer comparison

Andreas Raab andreas.raab at gmx.de
Wed Feb 18 01:00:43 UTC 2004


> On my trials I found out, that values of large postive integer don't
> equal values of integer even if the values represent the same value.
> Is this behaviour intended?

Yes. Only normalized integers will compare correctly. This is an
optimization which you usuall don't see as it allows to be extremely fast if
we (for example) compare whether "100 factorial = 99 factorial" (equality
essentially degenerates to string equality).

>
> For example:
>
> (5883377743366005002288555544466433777 \\\ 2) =
> (5883377743366005002288555544466433777 \\ 2)
>
> results in false, although both expression answer 1, but the first
> expression answers a large postive int(1) and the last a int(1).

This will answer true:

(5883377743366005002288555544466433777 \\\ 2) normalize =
(5883377743366005002288555544466433777 \\ 2)

The point being that \\\ deliberately answers a non-normalized result.

Cheers,
  - Andreas




More information about the Squeak-dev mailing list