The issue I'm having is related to memory. I'm doing financial calculations on dollar amounts and currently my float precision is 64-bits. I'd like to reduce the precision down to at least 32-bits but so far have not found a way to specify this in R. Ideally, this would just be applied to a dataframe that has a number of columns some are ints and some are floats.
Knowing that the sizeof(float) is 32 bits may be sufficient, in general, but insufficient in all cases. IEEE 758 defines the well known 32-bit binary32 which is commonly implemented. But IEEE 758 also defines a 32-bit decimal32, which is primarily use for storage and not computation.
Floats generally come in two flavours: “single” and “double” precision. Single precision floats are 32-bits in length while “doubles” are 64-bits. Due to the finite size of floats, they cannot represent all of the real numbers - there are limitations on both their precision and range.
A double precision, floating-point number is a 64-bit approximation of a real number. The number can be zero or can range from -1.797693134862315E+308 to -2.225073858507201E-308, or from 2.225073858507201E-308 to 1.797693134862315E+308.
No, there is not -- at least not in 'base R' which has only one integer
and numeric
(floating point) type each, and their sizes are fixed.
You can inspect them (and more) via .Machine
-- see help(".Machine")
.
Now, for your dollar amounts you could of course resort to expressing things in cents instead in which case you could integer
-- which is generally half the size of numeric
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With