Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization]Nans and infinity in wide xml archive
From: Robert Ramey (ramey_at_[hidden])
Date: 2017-07-04 17:38:55


On 7/4/17 10:01 AM, Paul A. Bristow via Boost-users wrote:

>> I would wonder though. I'm not sure that the Nan literals are standard.
>> I also don't trust them to be portable. Also to me it's a problem
>> with stream i/o rather than serialization itself. So my instinct would
>> have been to maybe make a custom manipulator or something like that. But
>> still, you've got a solution which looks like it will work well for your
>> needs so good luck with this.
>
> http://www.boost.org/doc/libs/1_64_0/libs/math/doc/html/math_toolkit/fp_facets/facets_intro.html
>
> has some info on this:
>
> "C99 standard for output of infinity and NaN
>
> The C99 standard does specify how infinity and NaN are formatted by printf and similar output functions, and parsed by scanf and
> similar input functions.
>
> The following string representations are used:
>
> Table 2.1. C99 Representation of Infinity and NaN
>
> number
>
> string
> Positive infinity
> "inf" or "infinity"
> Positive NaN
> "nan" or "nan(...)"
> Negative infinity
> "-inf" or "-infinity"
> Negative NaN
> "-nan" or "-nan(...)"
>
> So following C99 provides a sensible 'standard' way of handling input and output of nonfinites in C++, and this implementation
> follows most of these formats."
>
> And Elizabeta's solution is close to this. Using lower case might become more 'Standard'.
>
> I don't know of any progress in a 'Standard' representation in C++14, 17 ....
>
> HTH
>

This is all very interesting! I know some time ago when this problem
first came up (I'm always getting the blame for this!) There was some
work in addressing it. I didn't take part because I was sort of burned
out on working on the serialization library. But I would think it would
be a good thing if this could be "resolved" via a combination of
documentation and code so provide a canonical C++ solution which would
be compatible with just C++ stream i/o and hence automatically apply to
the the serialization library.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net