Skip to content
Prev 393548 / 398503 Next

gmp::bigq vs. MASS::fractions

On Sat, 7 Jan 2023 17:29:35 +0100
Sigbert Klinke <sigbert at wiwi.hu-berlin.de> wrote:

            
That's a consequence of the way fractions are internally represented
inside most modern processors. In short, gmp::as.bigq takes the red
pill and shows you the reality as it is (all fractions have a limited
number of significant digits -- 52 binary digits -- and are required to
have a denominator that's a power of two), while MASS::fractions tries
to guess what the original number might have been before an imprecise
approximation of k/7 had been computed. (Since 7 is not a power of 2,
only 0 and 1 have an exact representation in your example.)

For more information, see R FAQ 7.31:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

What do you need the fractions for?