define gcd 0 0 = 0 (Ticket #3304)

kahl at cas.mcmaster.ca kahl at cas.mcmaster.ca
Wed Jul 8 09:57:13 EDT 2009


Henning Thielemann antwortete roconnor at theorem.ca:
 > 
 > > As much as I'd love gcd 0 0 to be 0, the major problem is that this change 
 > > would contradict the Haskell 98 report.
 > 
 > There was a long thread about this issue some years ago that came to the 
 > conclusion that the current behaviour of gcd is algebraically most
 > sound.

Huh?

Algebraically, gcd is the binary greatest-lower-bound operation
in the divisibility ordering of the naturals,
or in the divisibility preordering on the integers.

In both, 0 is the unique top element (everything divides zero).

Therefore, ``gcd 0 0 = 0'' is even ``more algebraically justified'' than
``gcd (-2) (-6) = 2'', which is what both hugs and ghc produce.


Wolfram


More information about the Libraries mailing list