summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2014-08-18 05:16:00 +0000
committerrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2014-08-18 05:16:00 +0000
commitadfa7020c12799f526c620535c6bc464e16e56b4 (patch)
tree2dbadb96e2bf2bb0f5bbade09ee388aa0df747db
parent9360a0e3ea960cd76f9ca98f3ada1cc2f4c00b28 (diff)
be more careful acting on unary "-"
in order to parse "-0." correctly, use the copysing functionality of C99 rather than using a=-a to invert the sign. git-svn-id: http://svn.cactuscode.org/flesh/trunk@5125 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--src/piraha/Call.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/piraha/Call.cc b/src/piraha/Call.cc
index f4bfefe7..1f6969e8 100644
--- a/src/piraha/Call.cc
+++ b/src/piraha/Call.cc
@@ -542,7 +542,9 @@ smart_ptr<Value> meval(smart_ptr<Group> gr) {
if(ret->type == PIR_INT) {
ret->idata = -ret->idata;
} else if(ret->type == PIR_REAL) {
- ret->ddata = -ret->ddata;
+ ret->ddata = std::copysign(ret->ddata,
+ std::signbit(ret->ddata) ?
+ 1. : -1.);
} else {
std::ostringstream msg;
msg << "Unknown operation: " << unop << ret->type << std::endl;