mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18:20 +00:00
Use math.copysign to distinguish indeterminates
We were using a very dubious method to distinguish an indeterminate from a NaN, via struct.unpack. Turns out that math.copysign gets the job done and seems more robust.
This commit is contained in:
parent
b06ac33b5f
commit
60f257279b
1 changed files with 1 additions and 2 deletions
|
@ -1024,8 +1024,7 @@ def llList2CSV(lst):
|
|||
for elem in lst:
|
||||
# This always uses LSO rules for float to string.
|
||||
if type(elem) == float:
|
||||
from struct import pack
|
||||
if math.isnan(elem) and pack('>f', elem)[0:1] == b'\xff':
|
||||
if math.isnan(elem) and math.copysign(1.0, elem) < 0:
|
||||
ret.append(u'-nan')
|
||||
else:
|
||||
ret.append(u'%.6f' % elem)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue