Possible Duplicate:
Why are these numbers not equal?
in Gnu R:
which(seq(0, 1600, 0.05) == 0.3) returns
integer(0)
but this:
which(round(seq(0, 1600, 0.05),2) == 0.3) returns
[1] 7
What happens with the seq() function?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is essentially R FAQ 7.31 on comparisons between floats — leading to the famous ‘What every Computer Scientist should know about floating point numbers’.
In a nutshell, use
identical()and other helper functions to compare relative to a small value \epsilon as perfect equality cannot be had with floating point types.