[pure-lang-svn] SF.net SVN: pure-lang:[493] pure/trunk/lib/math.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-14 12:30:06
|
Revision: 493 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=493&view=rev Author: agraef Date: 2008-08-14 12:30:15 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Bugfixes in num/den and number predicates. Modified Paths: -------------- pure/trunk/lib/math.pure Modified: pure/trunk/lib/math.pure =================================================================== --- pure/trunk/lib/math.pure 2008-08-14 12:22:54 UTC (rev 492) +++ pure/trunk/lib/math.pure 2008-08-14 12:30:15 UTC (rev 493) @@ -443,10 +443,12 @@ den (x%y) = y; num x::int | -num x::bigint = x; +num x::bigint = bigint x; +num x::double = if frac x==0.0 then bigint x else num (rational x); den x::int | -den x::bigint = 1; +den x::bigint = 1L; +den x::double = if frac x==0.0 then 1L else den (rational x); /* Absolute value and sign. */ @@ -577,9 +579,9 @@ compvalp x = numberp x; realvalp x = compvalp x && im x==0; -ratvalp x = realvalp x && (y-y!==nan when y = re x end); -bigintvalp x = ratvalp x && den x==1; -intvalp x = bigintvalp && int x==x; +ratvalp x = realvalp x && re (x-x)!==nan; +bigintvalp x = ratvalp x && den (re x)==1; +intvalp x = bigintvalp x && int (re x)==x; /* Check whether a number is exact (i.e., doesn't contain any double components. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |