Skip to content

log10 error ?? (PR#1077)

2 messages · Christian Schulz, Martin Maechler

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

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

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

Version:
 platform = sparc-sun-solaris2.7
 arch = sparc
 os = solaris2.7
 system = sparc, solaris2.7
 status = 
 major = 1
 minor = 3.0
 year = 2001
 month = 06
 day = 22
 language = R

Search Path:
 .GlobalEnv, package:RODBC, package:MASS, package:prlib, package:pllib,
package:mathlib, package:mva, package:strlib, package:chlib, Autoloads,
package:base

Dr.sc.math.Christian W. Hoffmann
Mathematics and Statistical Computing
Landscape Modeling and Web Applications
Swiss Federal Research Institute WSL 
Zuercherstrasse 111
CH-8903 Birmensdorf, Switzerland
phone: ++41-1-739 22 77    fax: ++41-1-739 22 15
e-mail: christian.hoffmann_at_wsl.ch__prevent_spamming
www: http://www.wsl.ch/staff/christian.hoffmann/


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