[Rd] log10 error ?? (PR#1077)

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Tue, 28 Aug 2001 10:34:51 +0200


>>>>> "ChHo" == christian hoffmann <christian.hoffmann@wsl.ch> writes:

    ChHo> format((1000000*(1+.Machine$double.eps)),digits=18)
    ChHo> [1] "1000000.0000000002"
    >> .Machine$double.rounding
    ChHo> [1] 5
    ChHo> format(log10(1000000*(1+.Machine$double.eps)),digits=18)
    ChHo> [1] "5.9999999999999991"  # MUST be > 6 !!!???

no. 
you assume that every arithmetic operation is correct to the last
bit, which is too much. Note that you have two conversions
decimal <-> binary, and  log10(x) internally really maps to log(x)/log(10)
(where log(10) is stored as constant).


    ChHo> format((1000000*(1-.Machine$double.eps)),digits=18)
    ChHo> [1] " 999999.9999999998"
    >> format(log10(1000000*(1-.Machine$double.eps)),digits=18)
    ChHo> [1] "5.9999999999999991"  

    ChHo> format(10^5.9999999999999991,digits=18)
    ChHo> [1] "999999.9999999979"

You have to expect more than one bit difference..
Definitely no bug.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._