mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Change (float)"NaN" to (-1e40*0) in output.
Solves both an inconsistency and the need to create a string.
This commit is contained in:
parent
6faa7816e6
commit
a5ec12c9e9
1 changed files with 4 additions and 6 deletions
|
@ -21,7 +21,7 @@ import lslfuncs
|
||||||
import lslcommon
|
import lslcommon
|
||||||
from lslcommon import Key, Vector, Quaternion
|
from lslcommon import Key, Vector, Quaternion
|
||||||
from lslparse import warning
|
from lslparse import warning
|
||||||
import math
|
from math import copysign
|
||||||
|
|
||||||
class outscript(object):
|
class outscript(object):
|
||||||
|
|
||||||
|
@ -71,19 +71,17 @@ class outscript(object):
|
||||||
if tvalue == float:
|
if tvalue == float:
|
||||||
if self.optfloats and value.is_integer() and -2147483648.0 <= value < 2147483648.0:
|
if self.optfloats and value.is_integer() and -2147483648.0 <= value < 2147483648.0:
|
||||||
if self.globalmode and not self.listmode:
|
if self.globalmode and not self.listmode:
|
||||||
if value == 0 and math.copysign(1, value) == -1:
|
if value == 0 and copysign(1, value) == -1:
|
||||||
return '-0.'
|
return '-0.'
|
||||||
return str(int(value))
|
return str(int(value))
|
||||||
elif not self.globalmode:
|
elif not self.globalmode:
|
||||||
# Important inside lists!!
|
# Important inside lists!!
|
||||||
if value == 0 and math.copysign(1, value) == -1:
|
if value == 0 and copysign(1, value) == -1:
|
||||||
return '(-(float)0)'
|
return '(-(float)0)'
|
||||||
return '((float)' + str(int(value)) + ')'
|
return '((float)' + str(int(value)) + ')'
|
||||||
s = repr(value)
|
s = repr(value)
|
||||||
if s == 'nan':
|
if s == 'nan':
|
||||||
if math.copysign(1, value) < 0: # Indeterminate
|
return '(1e40*0)' if copysign(1, value) < 0 else '(-1e40*0)'
|
||||||
return '(1e40*0)'
|
|
||||||
return '((float)"NaN")' # this shouldn't appear in globals
|
|
||||||
if s == 'inf':
|
if s == 'inf':
|
||||||
return '1e40'
|
return '1e40'
|
||||||
if s == '-inf':
|
if s == '-inf':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue