From 2cf5ede81733bb78e9bd323130547acbb3825d7e Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Thu, 12 Jan 2017 15:05:34 +0100 Subject: [PATCH] Fix optimization of -0.0. It was optimized to ((float)0) because integers are cheaper. But that loses the sign, so that needed to be fixed. --- lslopt/lsloutput.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lslopt/lsloutput.py b/lslopt/lsloutput.py index f5501d4..85b6c84 100644 --- a/lslopt/lsloutput.py +++ b/lslopt/lsloutput.py @@ -70,9 +70,13 @@ class outscript(object): if tvalue == float: if self.optfloats and value.is_integer() and -2147483648.0 <= value < 2147483648.0: if self.globalmode and not self.listmode: + if value == 0 and math.copysign(1, value) == -1: + return '-0.' return str(int(value)) elif not self.globalmode: # Important inside lists!! + if value == 0 and math.copysign(1, value) == -1: + return '(-(float)0)' return '((float)' + str(int(value)) + ')' s = repr(value) if s == 'nan':