Re: equality of t_INTMODs

Karim Belabas <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
* Max Alekseyev [2025-01-24 17:56]:
> Hi Karim,
> 
> On "===" vs "==", what are other notable cases when the two give different
> results?

There are many:

  ? 1. == 0E38 \\ at default precision
  %1 = 1

  ? [] == 0
  %2 = 1
 
  ? 1 == [1,0,0]~
  %3 = 1

  ? Mod(1,2) == 1
  %4 = 1

etc.

> Do I understand correctly, that internally functions in PARI/GP, such as
> setsearch(), rely on "===" rather than "=="?

Mostly yes. They rely on cmp(), which is a universal comparison function.
Mathematically meaningless but transitive, and it guarantees
  cmp(x,y) == 0 if and only if x === y

Cheers,

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.