It's possible to enter Infinity as a float constant, so do that rather than the (float)"inf" kludge. It remains for NaN though.

This commit is contained in:
Sei Lisa 2016-01-06 01:21:04 +01:00
parent 881a33a427
commit c555a01a48
2 changed files with 9 additions and 5 deletions

View file

@ -71,8 +71,13 @@ class outscript(object):
# Important inside lists!!
return '((float)' + str(int(value)) + ')'
s = repr(value)
if s in ('inf', '-inf', 'nan'):
if s == 'nan':
return '((float)"' + s + '")' # this shouldn't appear in globals
if s in ('inf', '-inf'):
s = '1e40' if s == 'inf' else '-1e40'
if self.globalmode:
return s
return '((float)' + s + ')'
# Try to remove as many decimals as possible but keeping the F32 value intact
exp = s.find('e')
if ~exp: