Bug 16277 - Proposal for advanced huge number handling
Summary: Proposal for advanced huge number handling
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Accuracy (show other bugs)
Version: R 3.1.2
Hardware: All Windows 64-bit
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-03-23 13:37 UTC by Csaba Farago
Modified: 2015-03-30 07:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Csaba Farago 2015-03-23 13:37:44 UTC
If a value exceeds a threshold (about 10^309) it is "rounded up" to infinity (Inf). This may lead to wrong results even if a proper one could be calculated. For example:

> 10^500 * 0
[1] NaN

We definitely know that multiplying any constant with 0 results 0. On the other hand, multiplying infinity with 0 leads to undefined result, i.e. the following is correct:

> Inf * 0
[1] NaN

I propose is to introduce a new artificial value (similar to Inf, NA and NaN), let's say Huge. That would be the value when a number is so big that R is unable to handle it. The proposed differences and connections between Inf and Huge are the following:

Huge * 0 = 0
(Inf * 0 = NaN)

Inf > Huge = TRUE

Huge > Huge = NA
Huge == Huge = NA

Inf - Huge = Inf
(Inf - Inf = NaN)

All the other operations with Huge could be the same as in case of Inf.
Comment 1 Csaba Farago 2015-03-23 13:44:44 UTC
Similarly, Tiny could be introduced for handling close to 0 value handling.
Comment 2 Richard Cotton 2015-03-30 07:06:19 UTC
If you need to work with very large numbers, the Brobdingnag package is a more sophisticated solution.

http://cran.r-project.org/web/packages/Brobdingnag/index.html