Re: Parsing of maximum double parses INF
Olaf Peter <[email protected]> Fri, 1 Jun 2018 11:10:16 +0200
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
Am 31.05.2018 um 15:13 schrieb Olaf Peter:
> Hi,
>
> I came to the following test:
>
> #include <boost/spirit/home/x3.hpp>
> #include <iostream>
> #include <limits>
> #include <string>
>
> namespace x3 = boost::spirit::x3;
>
> int main()
> {
> std::string number{
> std::to_string(std::numeric_limits<double>::max()) };
>
> auto iter = number.begin();
> auto const end = number.end();
> double attr;
> bool parse_ok = x3::parse(iter, end,
> x3::double_,
> attr);
>
> std::cout << number << "\n"
> << std::boolalpha
> << "parse_ok: " << parse_ok
> << ", full_match: " << (iter == end)
> << ", attr: " << attr << "\n";
> }
>
> 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
>
> parse_ok: true, full_match: true, attr: inf
>
> where parse_ok and full_match are true, but the attribute got INF. I'm
> correct with my assumption, that a string of DOUBLE_MAX must give me the
> value back, isn't it? Isn't the same true for the smallest value as of
> std::numeric_limits<double>::min() ??
So, comparing is only usefull in the sence of
numeric_limits<double>::digits10, but nevertheless INF should not be,
isn't it?
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general