[Rd] precision of do_arith() in arithmetic.c

M Kim mkim0710 at gmail.com
Wed May 24 04:24:33 CEST 2017


To the R development team:

First of all, thank you so much for maintaining wonderful R software.

Perhaps, Dr. Ahn has just reported an error on the wilcox.test() function,
and suggesting that an error may arise from abs() and rank().


I just had a quick check that the problem may come from the precision of
the results of arithmetic functions.


87.7-89.1+1.4
# > 87.7-89.1+1.4
# [1] 8.437695e-15

I checked that do_arith() in arithmetic.c is using double type (8 byte) for
PLUSOP, MINUSOP, TIMESOP, DIVOP etc.

https://github.com/wch/r-source/blob/f68b30e3b5479d84adbff516d48d4722a574dc82/src/main/arithmetic.c


I have two thoughts:

(1) in the rank() function, we may round at less than 14 decimal places by
default?

(2) using long double type (10 byte) instead of double type (8 byte) by
default in the arithmetic function could be helpful for preventing
embarassment?

Perhaps, R may provide the arithmetic function with various variable types,
if some application needs.


Thanks.

Min-hyung

	[[alternative HTML version deleted]]



More information about the R-devel mailing list