Open minemR opened 1 year ago
Using bignum I encountered that portion of numerics (99994999999991:99999999999769) are not converted correctly:
bignum
library(openssl) bignum(99994999999990) # [b] 99994999999990 # correct bignum(99994999999991) # + 1 # [b] 100000000000000 # incorrect bignum(99999999999769) # + 5e+09 # [b] 100000000000000 # incorrect bignum(99999999999770) # + 1 # [b] 99994999999990 # correct
but, if we use character, conversion is correct:
character
bignum('99994999999991') # [b] 99994999999991
Looking at undelaying code we can see that formatC is to be blamed:
formatC
formatC(99994999999991, format = "fg") # [1] "100000000000000"
Maybe this could be fixed replacing formatC with format?
format
format(99994999999991, scientific = F) # "99994999999991" format(99994999999991.11, scientific = F) # "99994999999991" # should warn? format(1.13, scientific = F) # "1.13"
Or maybe conversion from double should be turned off and the pitfalls should be described in help?
Using
bignum
I encountered that portion of numerics (99994999999991:99999999999769) are not converted correctly:but, if we use
character
, conversion is correct:Looking at undelaying code we can see that
formatC
is to be blamed:Maybe this could be fixed replacing
formatC
withformat
?Or maybe conversion from double should be turned off and the pitfalls should be described in help?