This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author akira
Recipients akira, brg@gladman.plus.com, gladman, mark.dickinson, scoder, vstinner
Date 2014-09-24.11:43:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1411559019.22.0.206084672255.issue22477@psf.upfronthosting.co.za>
In-reply-to
Content
Whether or not gcd(a, b) == gcd(|a|, |b|) depends on the definition if
we believe to Stepanov of C++ STL fame who mentions in his lecture [1]

[1] http://www.stepanovpapers.com/gcd.pdf

that the current implementation that uses two operation __bool__ and 
__mod__:

  def gcd(a, b):
      while b:
          a, b = b, a%b
      return a

can be applied to Euclidean ring elements (not just positive or
negative integers). Despite Knuth’s objection to gcd(1, -1) = -1, 
adding `if a < 0: a = -a` at the end changes the requirements for the
type. Here's the definition from the lecture [1]:

  Greatest common divisor is a common divisor that is divisible by any 
  other common divisor.

I have no opinion on whether or not fractions.gcd() should be changed. 
I thought that I should mention that different definitions exist.
History
Date User Action Args
2014-09-24 11:43:39akirasetrecipients: + akira, mark.dickinson, scoder, vstinner, gladman, brg@gladman.plus.com
2014-09-24 11:43:39akirasetmessageid: <1411559019.22.0.206084672255.issue22477@psf.upfronthosting.co.za>
2014-09-24 11:43:39akiralinkissue22477 messages
2014-09-24 11:43:38akiracreate