Just to add a small note,
sin(pi) is below machine precision :

> .Machine$double.eps
[1] 2.220446e-16

(see ?.Machine for exact definition)

-> if myval is bounded to be positive, one safe way of testing equality to
0 would then be "myval < .Machine$double.eps"



On Thu, Sep 26, 2013 at 2:48 PM, Suzen, Mehmet <msuzen@gmail.com> wrote:

> On 26 September 2013 11:30, Rainer M Krug <Rainer@krugs.de> wrote:
> >>>> Why doesn't return me 0?
>
> It isn't R question at all. You might want to read about representing
> real numbers in a computer using floating point
> http://en.wikipedia.org/wiki/Floating_point
>
> If you want more precision for some reason, you may want to use Rmpfr
> package from CRAN, for example
> > require(Rmpfr)
> > pii <- mpfr(pi, 1200)
> > sin(pii)
> 1 'mpfr' number of precision  1200   bits
> [1]
> 1.22464679914735317722606593227499799708305390129979194948825771626086960997325810377509325527569013655456428540074414189136673810003656057935764118217436637676835016019778833613838580470703060741630570066750947925902443295873487819032259435513861185501796412843027607796970259523768923503206248925733373776859085615900203929142965774524665617260404787862664073939e-16
>
>
> > | > Is that a Fortune? And, if so, should R be using computers?
>
> Don't blame R for real numbers.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

