[R] Rounding problem R vs Excel
Martin Maechler
maechler at stat.math.ethz.ch
Wed Jun 11 08:51:11 CEST 2003
Thanks a lot, Marc, for this extra insight.
Note that Sun / Openoffice.org 's approxEqual(a,b)
is not even symmetric in a and b which I think is *really wrong*
((S's somewhat related all.equal.numeric() method *is* symmetric))
>>>>> "Marc" == Marc Schwartz <MSchwartz at medanalytics.com>
>>>>> on 10 Jun 2003 14:41:53 -0500 writes:
Marc> Hi all,
Marc> I thought that I would follow up on this thread with some "refined"
Marc> information.
<.......>
>> Copyright: 2002 by Sun Microsystems, Inc.
>>
>> /** Test equality of two values with an accuracy of the magnitude of the
>> given values scaled by 2^-48 (4 bits roundoff stripped).
>>
>> @ATTENTION
>> approxEqual( value!=0.0, 0.0 ) _never_ yields true.
>> */
>> inline bool approxEqual(double a, double b)
>> {
>> if ( a == b )
>> return true;
>> double x = a - b;
>> return (x < 0.0 ? -x : x)
>> < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
>> }
Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
More information about the R-help
mailing list