tidyverse / vroom

Fast reading of delimited files
https://vroom.r-lib.org
Other
622 stars 60 forks source link

Why the data are different using vroom_write and vroom #531

Closed ZTZK closed 5 months ago

ZTZK commented 5 months ago

Hi, Thanks for creating this package. It's awesome. I encountered a problem with the vroom_write. Below is the code.

number=0.8914392590522770554173
data1=tibble::tibble(c1=number)
vroom::vroom_write(data1,"testnumber.csv")
data2=vroom::vroom("testnumber.csv",delim = ",")
data1$c1[1]==data2$c1[1]

The result shows that two numbers are different. I wonder why this happens. image

jennybc commented 5 months ago

This is a matter of floating point numbers and is not specific to vroom (or R, even). But here's the most relevant R FAQ that explains this:

https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f-1