-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double parser cannot handle numbers > 1e19 which are not in scientific notation #412
Comments
Works for me: readr::parse_double("10000000000000000000000")
#> [1] 1e+22 Can you please try with the dev version of readr? |
I did that already. I have the problem with CRAN version 0.2.2 and lastest git version (8312374) on Ubuntu 16.04 (and 14.04): readr::parse_double("10000000000000000000000")
# Warning: 1 parsing failure.
# row col expected actual
# 1 -- a double 10000000000000000000000
# [1] NA
# attr(,"problems")
# Source: local data frame [1 x 4]
#
# row col expected actual
# <int> <int> <chr> <chr>
# 1 1 NA a double 10000000000000000000000
devtools::session_info()
# Session info -------------------------------------------------------------------
# setting value
# version R version 3.3.0 (2016-05-03)
# system x86_64, linux-gnu
# ui X11
# language (EN)
# collate en_US.UTF-8
# tz <NA>
# date 2016-06-02
#
# Packages -----------------------------------------------------------------------
# package * version date source
# assertthat 0.1 2013-12-06 CRAN (R 3.3.0)
# BH * 1.60.0-2 2016-05-07 CRAN (R 3.3.0)
# devtools 1.11.1 2016-04-21 CRAN (R 3.3.0)
# digest 0.6.9 2016-01-08 CRAN (R 3.3.0)
# memoise 1.0.0 2016-01-29 CRAN (R 3.3.0)
# Rcpp 0.12.5 2016-05-14 CRAN (R 3.3.0)
# readr 0.2.2.9000 2016-06-02 Github (hadley/readr@8312374)
# tibble 1.0 2016-03-23 CRAN (R 3.3.0)
# withr 1.0.1 2016-02-04 CRAN (R 3.3.0) |
And you have the same version of BH as me, so it's not a different version of boost::spirit. I'm at a loss. |
Your test was on a Mac? |
I can also reproduce the problem on my iMac: readr::parse_double("100000000000000000000")
# Warning: 1 parsing failure.
# row col expected actual
# 1 -- a double 100000000000000000000
# [1] NA
# attr(,"problems")
# Source: local data frame [1 x 4]
#
# row col expected actual
# <int> <int> <chr> <chr>
# 1 1 NA a double 100000000000000000000
devtools::session_info()
# Session info ------------------------------------------------------------------
# setting value
# version R version 3.3.0 (2016-05-03)
# system x86_64, darwin13.4.0
# ui AQUA
# language (EN)
# collate C
# tz Europe/Vienna
# date 2016-06-02
#
# Packages ----------------------------------------------------------------------
# package * version date source
# BH * 1.60.0-2 2016-05-07 CRAN (R 3.3.0)
# R6 2.1.2 2016-01-26 CRAN (R 3.3.0)
# Rcpp 0.12.5 2016-05-14 CRAN (R 3.3.0)
# assertthat 0.1 2013-12-06 CRAN (R 3.3.0)
# curl 0.9.7 2016-04-10 CRAN (R 3.3.0)
# devtools 1.11.1 2016-04-21 CRAN (R 3.3.0)
# digest 0.6.9 2016-01-08 CRAN (R 3.3.0)
# git2r 0.15.0 2016-05-11 CRAN (R 3.3.0)
# httr 1.1.0 2016-01-28 CRAN (R 3.3.0)
# memoise 1.0.0 2016-01-29 CRAN (R 3.3.0)
# readr 0.2.2.9000 2016-06-02 Github (hadley/readr@19d6eaf)
# tibble 1.0 2016-03-23 CRAN (R 3.3.0)
# withr 1.0.1 2016-02-04 CRAN (R 3.3.0) |
Just to make sure we're as close as possible, can you please start R from the console with
|
Installed dev version of > devtools::session_info("readr")
# Session info -------------------------------------------------------------------
# setting value
# version R version 3.3.0 (2016-05-03)
# system x86_64, darwin13.4.0
# ui X11
# language (EN)
# collate en_US.UTF-8
# tz Europe/Vienna
# date 2016-06-02
#
# Packages -----------------------------------------------------------------------
# package * version date source
# assertthat 0.1 2013-12-06 CRAN (R 3.3.0)
# BH 1.60.0-2 2016-05-07 CRAN (R 3.3.0)
# curl 0.9.7 2016-04-10 CRAN (R 3.3.0)
# lazyeval 0.1.10.9000 2016-06-02 Github (hadley/lazyeval@bce211b)
# Rcpp 0.12.5 2016-05-14 CRAN (R 3.3.0)
# readr 0.2.2.9000 2016-06-02 Github (hadley/readr@19d6eaf)
# tibble 1.0-5 2016-06-02 Github (hadley/tibble@64175a8)
readr::parse_double("100000000000000000000")
# Warning: 1 parsing failure.
# row col expected actual
# 1 -- a double 100000000000000000000
# [1] NA |
It works when using |
Hmmmmm, what compiler are you using? (if you don't know, you should be able to see when installing one of the packages from source - look for either gcc or clang) |
This was with default
I also did some tests directly in C++:
|
I bet that's the difference - I use I think there are some non obvious consequences to using |
It does not require C++11. C++ source: #include <boost/spirit/include/qi.hpp>
#include <iostream>
int main() {
std::string s = "1000000000000000000000.00";
std::string::const_iterator first(boost::begin(s)), last(boost::end(s));
double res1 = -1;
std::cout << "return value (qi::long_double): " << boost::spirit::qi::parse(first, last, boost::spirit::qi::long_double, res1) << std::endl;
std::cout << "parse result: " << res1 << std::endl;
double res2 = -1;
std::cout << "return value (qi::double_): " << boost::spirit::qi::parse(first, last, boost::spirit::qi::double_, res2) << std::endl;
std::cout << "parse result: " << res2 << std::endl;
} Ubuntu 16.04 (x64):
OS X 10.11.5 with Xcode CommandlineTools v7.3
|
But long doubles are only available in C99, which is what C++11 uses. |
Yesterday I spent some time to test several boost versions with clang and gcc. There is a Trac ticket (reported Sep 2015): https://svn.boost.org/trac/boost/ticket/11608 |
|
Yes,
|
This works around an unaddressed spirit regression (https://svn.boost.org/trac/boost/ticket/11608). Fixes tidyverse#412
I observed parsing failures with large numbers/doubles.
In scientific notation there are no failures.
Maybe a problem with
boost::spirit::qi::parse()
.The text was updated successfully, but these errors were encountered: