From adfa7020c12799f526c620535c6bc464e16e56b4 Mon Sep 17 00:00:00 2001 From: rhaas Date: Mon, 18 Aug 2014 05:16:00 +0000 Subject: 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 --- src/piraha/Call.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 meval(smart_ptr 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; -- cgit v1.2.3