Skip to content
Back to formatted view

Raw Message

Message-ID: <4D3DD78B.8000707@gmx.de>
Date: 2011-01-24T19:48:27Z
From: Marc Jekel
Subject: sensitivity logical operators in R
In-Reply-To: <4D3CA7F7.1030601@gmx.de>

Hi again,

I have checked the same code (see below) using MATLAB. It produces the 
same error (i.e., equal numbers are evaluated as unequal). Do I miss 
something?

Thanks for help!

Marc

Marc Jekel schrieb:
> Hello R Fans,
>
> Another question for the community that really frightened me today. 
> The following logical comparison produces a "false" as output:
>
> t = sum((c(.7,.69,.68,.67,.66)-.5)*c(1,1,-1,-1,1))
> tt = sum((c(.7,.69,.68,.67,.66)-.5)*c(1,-1,1,1,-1))
>
> t == tt
>
> This is really strange behavior. Most likely this has something to do 
> how R represents numbers internally and the possible sensitivity of a 
> computer? Does anyone know when this strange behavior occurs and how 
> to fix it?
>
> Thank you all! This list is pleasure!!!
>
> Marc
>