Skip to content

Double parser cannot handle numbers > 1e19 which are not in scientific notation #412

@defconst

Description

@defconst

I observed parsing failures with large numbers/doubles.
In scientific notation there are no failures.
Maybe a problem with boost::spirit::qi::parse().

x <- "10000000000000000000"
as.double(x)
# [1] 1e+19
readr::parse_double(x)
# [1] 1e+19


x <- "100000000000000000000"
as.double(x)
# [1] 1e+20
readr::parse_double(x)
# 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

readr::parse_double("1e+20")  # this works
# [1] 1e+20

readr::read_csv("x\n100000000000000000000.0", col_types="d", col_names=TRUE)
# Warning: 1 parsing failure.
# row col expected                  actual
#   1   x a double 100000000000000000000.0
#    x
#1 NA

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions