简体   繁体   中英

Difference between double- precision data type and numeric data type

R编程中双精度数据类型和数值数据类型之间的显着差异是什么?

From stat.ethz.ch:

It is a historical anomaly that R has two names for its floating-point vectors, double and numeric (and formerly had real). double is the name of the type. numeric is the name of the mode and also of the implicit class. As an S4 formal class, use "numeric". The potential confusion is that R has used mode "numeric" to mean 'double or integer'

We can think of doubles as belonging to numeric. To see this:

 > is.double(1)
 [1] TRUE
 > is.numeric(1)
 [1] TRUE

R normally stores numbers as doubles. Using "numeric()" is the same as "double()." You can also store a number as a single or an integer. Both will be numeric. You may choose to force a number be stored as an integer for performance reasons, but unless you are building a package the trade offs might not be worth your time.

I suggest reading Gillespie's Overview for more info on type and performance.

According to rdocumentation :

Details: numeric is identical to double (and real).

Hope it helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM