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.
This commit is contained in:
Sei Lisa 2017-01-12 15:05:34 +01:00
parent 4ec9396688
commit 2cf5ede817

View file

@ -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':