![]() ![]() ![]() The current `gcd` definition is almost accidental, in that it just happens to be what's convenient for use in normalisation in the Fraction type. If necessary a local function in the fractions module could maintain the current behaviour.Īuthor: Mark Dickinson (mark.dickinson) * I hence believe that consideration should be given to changing the behaviour of the Python greatest common divisor function to match the mathematical properties expected of this function. This behaviour is documented but I think it is undesirable to provide a function that has the well known and widely understood name 'gcd', but one that doesn't match the behaviour normally associated with this function. ![]() In particular gcd(a, b) = gcd(|a|, |b|).īut the Python version of this function in the fractions module doesn't conform to these properties since it returns a negative value when its second parameter is negative. ![]() The function known as 'the greatest common divisor' has a number of well defined mathematical properties for both positive and negative integers (see, for example, Elementary Number Theory by Kenneth Rosen). Nosy gladman, mark.dickinson, mrabarnett, scoder, serhiy.storchaka, steven.daprano, terry.reedy, vstinner, wolmaĬreated on 07:25 by last changed 14:58 by admin. ![]()
0 Comments
Leave a Reply. |