[pure-lang-svn] SF.net SVN: pure-lang:[762] pure/trunk/lib/primitives.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-09-15 05:34:49
|
Revision: 762 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=762&view=rev Author: agraef Date: 2008-09-15 05:34:59 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Properly handle the case of IEEE 754 negative zeros. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-15 04:56:26 UTC (rev 761) +++ pure/trunk/lib/primitives.pure 2008-09-15 05:34:59 UTC (rev 762) @@ -125,10 +125,13 @@ // Fractional part of x. frac x::int | frac x::bigint | frac x::double = x-trunc x; -/* Absolute value and sign of a number. */ +/* Absolute value and sign of a number. Note that these don't distinguish + between IEEE 754 positive and negative zeros; abs always returns 0.0, sgn 0 + for these. The real sign bit of a floating point zero can be obtained with + sgn (1/x). */ abs x::int | abs x::bigint | abs x::double - = if x>=0 then x else -x; + = if x>0 then x else -x; sgn x::int | sgn x::bigint | sgn x::double = if x>0 then 1 else if x<0 then -1 else 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |