[R] Why does the print method fail for very small numbers?

Helmut Schütz he|mut@@chuetz @end|ng |rom beb@c@@t
Sat Feb 19 16:00:39 CET 2022


Hi Marius,

as others already noted, you request something which is beyond the 
numeric resolution.
That's also elaborated in the famous FAQ 7.31 
(https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f).
As you know - according to IEEE 754 a binary in double precision holds 
64 bits (where 1 bit is the sign, 11 the exponent, and 52 the mantissa). 
That translates into ~15.7 digits decimal. Hence, the 16th digit is noise.

IMHO, print(foo, digits = bar) should provide the result but 
additionally throw for any bar > 15 a message like
"From the hard-/software to the wetware: We cannot provide what you were 
asking for."

Helmut

-- 
Ing. Helmut Schütz
BEBAC – Consultancy Services for
Bioequivalence and Bioavailability Studies
Neubaugasse 36/11
1070 Vienna, Austria
W https://bebac.at/
F https://forum.bebac.at/



More information about the R-help mailing list