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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user