Umm. pi has been rounded to 6 decimal places in the second example. So it isn't surprising that the results differ. sin(pi) is not zero, as it also has been rounded, and you can't represent irrational numbers exactly in a numerical form anyway. R agrees with Octave:
octave:1> sin(pi) ans = 1.2246e-16 octave:2> sin(3.141593) ans = -3.4641e-07 octave:3> To paraphrase someone else on this list: I think it is strange that you think it is strange. Simon. As someone On Mon, 2007-09-03 at 16:43 +1000, Nguyen Dinh Nguyen wrote: > Dear all, > I found something strange when calculating sin of pi value > sin(pi) > [1] 1.224606e-16 > > pi > [1] 3.141593 > > sin(3.141593) > [1] -3.464102e-07 > > Any help and comment should be appreciated. > Regards > Nguyen > > ____________________________ > Nguyen Dinh Nguyen > Garvan Institute of Medical Research > Sydney, Australia > > ______________________________________________ > R-help@stat.math.ethz.ch 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. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. ______________________________________________ R-help@stat.math.ethz.ch 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.