From 729c868342f0dcdd811502f7d693664d8528f445 Mon Sep 17 00:00:00 2001
From: Daniel Fischer <daniel.is.fischer@googlemail.com>
Date: Sun, 29 May 2011 19:33:57 +0200
Subject: [PATCH] New gcd documentation
Based on Ross Paterson's suggestion, a short explanation of the
meaning of gcd, and a mention of possible negative results.

GHC/Real.lhs  12 +++++++++
1 files changed, 9 insertions(+), 3 deletions()
diff git a/GHC/Real.lhs b/GHC/Real.lhs
index 51d7db4..27b1b6c 100644
a

b

x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) 
520  520  in if even e then (nn :% dd) else (negate nn :% dd) 
521  521  
522  522   
523     @'gcd' x y@ is the greatest (nonnegative) integer that divides both @x@ 
524    and @y@; for example @'gcd' (3) 6@ = @3@, @'gcd' (3) (6)@ = @3@, 
525    @'gcd' 0 4@ = @4@. @'gcd' 0 0@ = @0@. 
 523    @'gcd' x y@ is the nonnegative factor of both @x@ and @y@ of which 
 524   every common factor of @x@ and @y@ is also a factor; for example 
 525   @'gcd' 4 2 = 2@, @'gcd' (4) 6 = 2@, @'gcd' 0 4@ = @4@. @'gcd' 0 0@ = @0@. 
 526   (That is, the common divisor that is \"greatest\" in the divisibility 
 527   preordering.) 
 528   
 529   Note: Since for signed fixedwidth integer types, @'abs' 'minBound' < 0@, 
 530   the result may be negative if one of the arguments is @'minBound'@ (and 
 531   necessarily is if the other is @0@ or @'minBound'@) for such types. 
526  532  gcd :: (Integral a) => a > a > a 
527  533  gcd x y = gcd' (abs x) (abs y) 
528  534  where gcd' a 0 = a 