[Rd] 0.45<0.45 = TRUE (PR#10744)

Heikki Kaskelma kas.hei at nbl.fi
Wed Feb 13 02:15:34 CET 2008


hadley wickham:
> It's more than that as though, as floating point addition is no longer
> guaranteed to be commutative or associative, and multiplication does
> not distribute over addition.  Many concepts that are clear cut in
> pure math become fuzzy in floating point math - equality, singularity
> of matrices etc etc.

Even simple averages may be complicated:

eps=1
while(1-eps != 1) eps=eps/2
eps=eps*2

(1-1*eps+1-2*eps+1-3*eps)/3 == 1-1:3*eps    #  TRUE FALSE FALSE
mean(1-1:3*eps) == 1-1:3*eps    # FALSE  TRUE FALSE
sum(1-1:3*eps)/3 == 1-1:3*eps   # FALSE FALSE  TRUE
((1-1*eps)+(1-2*eps)+(1-3*eps))/3 == 1-1:3*eps   # FALSE FALSE  TRUE

so sometimes all the values may lie on the same side of the "average".

[Win R 2.6.1]


Heikki Kaskelma
Munkkiniemi, Finland



More information about the R-devel mailing list