0

I tend to read a large number from a string input and then convert it into numeric format. However, I always get wrong output.

#the input string is: "31415926535897932384626433832795"

My code is like this:

input <- readLines("stdin", warn = F)
options(scipen = 10^6)
nums <- as.numeric(input)
cat(nums)

the output is like this, the original number has been modified. I don't get what happened when importing and converting the string into numeric?

31415926535897933290036940242944  
Elsa Li
  • 673
  • 3
  • 9
  • 19

0 Answers0