[pure-lang-svn] SF.net SVN: pure-lang:[763] pure/trunk/printer.cc
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-09-15 05:45:08
|
Revision: 763 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=763&view=rev Author: agraef Date: 2008-09-15 05:45:18 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Properly handle the case of IEEE 754 negative zeros. Modified Paths: -------------- pure/trunk/printer.cc Modified: pure/trunk/printer.cc =================================================================== --- pure/trunk/printer.cc 2008-09-15 05:34:59 UTC (rev 762) +++ pure/trunk/printer.cc 2008-09-15 05:45:18 UTC (rev 763) @@ -76,7 +76,9 @@ else return 100; case EXPR::DBL: - if (x.dval() < 0.0) + /* NOTE: The check for negative zero really needs IEEE 754 floating point + numbers, otherwise we'll divide by zero here. */ + if (x.dval() < 0.0 || x.dval() == 0.0 && 1.0/x.dval() < 0.0) // precedence of unary minus: return sym_nprec(interpreter::g_interp->symtab.neg_sym().f); else @@ -577,7 +579,9 @@ else return 100; case EXPR::DBL: - if (x->data.d < 0.0) + /* NOTE: The check for negative zero really needs IEEE 754 floating point + numbers, otherwise we'll divide by zero here. */ + if (x->data.d < 0.0 || x->data.d == 0.0 && 1.0/x->data.d < 0.0) // precedence of unary minus: return sym_nprec(interpreter::g_interp->symtab.neg_sym().f); else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |