From Martin Maechler <maechler@stat.math.ethz.ch>  Tue Aug 28 09:34:51 2001
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Tue, 28 Aug 2001 10:34:51 +0200
Subject: [Rd] log10 error ?? (PR#1077)
In-Reply-To: <200108280640.IAA22157@pubhealth.ku.dk>
References: <200108280640.IAA22157@pubhealth.ku.dk>
Message-ID: <15243.22443.374714.952324@gargle.gargle.HOWL>

>>>>> "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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


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