On Fri, 4 Nov 2005, Peter Dalgaard wrote: > Uwe Ligges <[EMAIL PROTECTED]> writes: > >> Dr Carbon wrote: >> >>> At the risk of being beaten about the face and body, can somebody explain >>> why the middle example: log2(2^3); floor(log2(2^3)) is different than >>> examples 1 and 3? >> >> >> Because >> >> > log2(2^3) - 3 >> [1] -4.440892e-16 >> >> see the R FAQ "Why doesn't R think these numbers are equal?". >> >> Uwe Ligges > > In this particular case, it is slightly odd that we can't get an exact > answer for operations that could in principle be carried out using > integer arithmetic, but we're actually calculating log(8)/log(2). > > (Curiously, the same effect is not seen on Linux or Solaris until > > > log2(2^29)-29 > [1] 3.552714e-15 > > )
Yes, since there are C99/POSIX functions log2 and log10. We ought to make use of them if available (they are currently on Windows). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html