[pure-lang-svn] SF.net SVN: pure-lang: [418] pure/trunk/lib/math.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-07-08 08:47:36
|
Revision: 418 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=418&view=rev Author: agraef Date: 2008-07-08 01:47:45 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Handle x%0 like x div 0. Modified Paths: -------------- pure/trunk/lib/math.pure Modified: pure/trunk/lib/math.pure =================================================================== --- pure/trunk/lib/math.pure 2008-07-08 08:41:12 UTC (rev 417) +++ pure/trunk/lib/math.pure 2008-07-08 08:47:45 UTC (rev 418) @@ -361,14 +361,14 @@ /* The '%' operator returns a rational or complex rational for any combination of integer, rational and complex integer/rational arguments, provided that - the denominator is nonzero (otherwise it returns a floating point nan or - infinity, depending on the numerator). Machine int operands are always - promoted to bigints. For other numeric operands '%' works just like - '/'. Rational results are normalized so that the sign is always in the - numerator and numerator and denominator are relatively prime. Hence a - rational zero is always represented as 1L%0L. */ + the denominator is nonzero (otherwise it behaves like x div 0, which will + raise an exception on most systems). Machine int operands are always + promoted to bigints. For other numeric operands '%' works just like '/'. + Rational results are normalized so that the sign is always in the numerator + and numerator and denominator are relatively prime. Hence a rational zero + is always represented as 1L%0L. */ -x::bigint % 0L = x/0; +x::bigint % 0L = x div 0L; x::bigint % y::bigint = (-x)%(-y) if y<0; = (x div d) % (y div d) when d = gcd x y end if gcd x y > 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |