Index: boost/spirit/home/qi/numeric/detail/real_impl.hpp =================================================================== --- boost/spirit/home/qi/numeric/detail/real_impl.hpp (revision 84780) +++ boost/spirit/home/qi/numeric/detail/real_impl.hpp (working copy) @@ -238,19 +238,21 @@ { // No exponent found. Scale the number by -frac_digits. traits::scale(-frac_digits, n); - } - else if (traits::is_equal_to_one(n)) - { + // There is a chance of having to parse one of the 1.0#... // styles some implementations use for representing NaN or Inf. + if (frac_digits == 1 && traits::is_equal_to_one(n) && + (first != last && *first == '#')) + { + save = first; - // Check whether the number to parse is a NaN or Inf - if (p.parse_nan(first, last, n) || - p.parse_inf(first, last, n)) - { - // If we got a negative sign, negate the number - traits::assign_to(traits::negate(neg, n), attr); - return true; // got a NaN or Inf, return immediately + ++first; + // Check whether the number to parse is a NaN or Inf + if (!p.parse_nan(first, last, n) && + !p.parse_inf(first, last, n)) + { + first = save; + } } } Index: libs/spirit/test/qi/real2.cpp =================================================================== --- libs/spirit/test/qi/real2.cpp (revision 84780) +++ libs/spirit/test/qi/real2.cpp (working copy) @@ -69,7 +69,7 @@ using boost::math::fpclassify; using boost::spirit::detail::signbit; // Boost version is broken - + BOOST_TEST(test("-inf", double_)); BOOST_TEST(test("-infinity", double_)); BOOST_TEST(test_attr("-inf", double_, d) && @@ -83,6 +83,19 @@ BOOST_TEST(test_attr("-INFINITY", double_, d) && FP_INFINITE == fpclassify(d) && signbit(d)); + BOOST_TEST(test("-1.0#inf", double_)); + BOOST_TEST(test("-1.0#infinity", double_)); + BOOST_TEST(test_attr("-1.0#inf", double_, d) && + FP_INFINITE == fpclassify(d) && signbit(d)); + BOOST_TEST(test_attr("-1.0#infinity", double_, d) && + FP_INFINITE == fpclassify(d) && signbit(d)); + BOOST_TEST(test("-1.0#INF", double_)); + BOOST_TEST(test("-1.0#INFINITY", double_)); + BOOST_TEST(test_attr("-1.0#INF", double_, d) && + FP_INFINITE == fpclassify(d) && signbit(d)); + BOOST_TEST(test_attr("-1.0#INFINITY", double_, d) && + FP_INFINITE == fpclassify(d) && signbit(d)); + BOOST_TEST(test("-nan", double_)); BOOST_TEST(test_attr("-nan", double_, d) && FP_NAN == fpclassify(d) && signbit(d)); @@ -96,6 +109,20 @@ BOOST_TEST(test("-NAN(...)", double_)); BOOST_TEST(test_attr("-NAN(...)", double_, d) && FP_NAN == fpclassify(d) && signbit(d)); + + BOOST_TEST(test("-1.0#nan", double_)); + BOOST_TEST(test_attr("-1.0#nan", double_, d) && + FP_NAN == fpclassify(d) && signbit(d)); + BOOST_TEST(test("-1.0#NAN", double_)); + BOOST_TEST(test_attr("-1.0#NAN", double_, d) && + FP_NAN == fpclassify(d) && signbit(d)); + + BOOST_TEST(test("-1.0#nan(...)", double_)); + BOOST_TEST(test_attr("-1.0#nan(...)", double_, d) && + FP_NAN == fpclassify(d) && signbit(d)); + BOOST_TEST(test("-1.0#NAN(...)", double_)); + BOOST_TEST(test_attr("-1.0#NAN(...)", double_, d) && + FP_NAN == fpclassify(d) && signbit(d)); } return boost::report_errors();