Austin Bingham
2005-01-05 22:43:31 UTC
I saw a thread on this topic from a few months ago, and I was
wondering if there had been any progress or new thought on the topic.
Essentially, it appears that the serialization library can't reliably
deserialize the serialized version of NaN and infinity for doubles and
floats. This seems to be a result of relying on the, AFAIK, undefined
behavior of writing NaN/infinity to a stream; it will work correctly
with some standard library implementations, but not all.
I think the problem can be addressed with these changes:
basic_text_oprimitive::save(float or double): on NaN or Infinity,
write out some known, stable string (i.e. "nan" or "inf"); don't rely
on std implementation.
basic_text_iprimitive::load(float or double): look for the "known
values" printed by save(), generating the correct values when they're
seen.
That's a lot of hand waving, to be sure, but something like this would
really help out. Of course, a better solution would be fine with me,
but there are definitely cases where it's necessary to serialize these
values. Currently, there doesn't seem to be a way to reliably to it.
Austin Bingham
wondering if there had been any progress or new thought on the topic.
Essentially, it appears that the serialization library can't reliably
deserialize the serialized version of NaN and infinity for doubles and
floats. This seems to be a result of relying on the, AFAIK, undefined
behavior of writing NaN/infinity to a stream; it will work correctly
with some standard library implementations, but not all.
I think the problem can be addressed with these changes:
basic_text_oprimitive::save(float or double): on NaN or Infinity,
write out some known, stable string (i.e. "nan" or "inf"); don't rely
on std implementation.
basic_text_iprimitive::load(float or double): look for the "known
values" printed by save(), generating the correct values when they're
seen.
That's a lot of hand waving, to be sure, but something like this would
really help out. Of course, a better solution would be fine with me,
but there are definitely cases where it's necessary to serialize these
values. Currently, there doesn't seem to be a way to reliably to it.
Austin Bingham