0

我最近开始使用包 ROracle 在 R 和 Oracle 之间交换数据,但是在检索带有少量十进制数字的数字时遇到了精度问题。这是一个例子:

#With library ROracle:
eval(canale)
out<-dbGetQuery(conRORA, "select 1.39 from dual")
dbDisconnect(conRORA)
[1] TRUE
#Printing the result with lots of digits, it seems fine:
print(out[1,],digits=10)
[1] 1.39
#but:
out[1,]-1.39
[1] 2.22044604925e-16
#why can't it be a perfect zero?

#if I do the same with library RODBC instead:
eval(chNew)
out2<-sqlQuery(channelNew,"select 1.39 from dual",dec=",")
out2[1,]-1.39
[1] 0
odbcCloseAll()

那么,我怎样才能让 dbGetQuery 获得正确的位数?谢谢

4

0 回答 0