FAQ 7.31 This is what happens with floating point number and you are only printing out 7 digits of precision; look at the results > cos(-1.570796) [1] 0.0000003267949 > cos(-1.5707961) # just incrementing the digit that was not displayed [1] 0.0000002267949 > cos(-1.5707962) [1] 0.0000001267949 > cos(-1.5707963) [1] 0.00000002679490 > cos(-1.5707964) # notice the sign change [1] -0.0000000732051 >
On Tue, Jul 14, 2009 at 1:45 PM, Nair, Murlidharan T<mn...@iusb.edu> wrote: > I am trying to calculate coordinate transformations and in the process of > debugging my code using debug I found the following > > Browse[1]> direction[i] > [1] -1.570796 > Browse[1]> cos(direction[i]) > [1] 6.123032e-17 > Browse[1]> cos(-1.570796) > [1] 3.267949e-07 > Browse[1]> direction[i] > [1] -1.570796 > Browse[1]> cos(direction[i]) > [1] 6.123032e-17 > Browse[1]> cos(-1.570796) > [1] 3.267949e-07 > Browse[1]> x<-direction[i] > Browse[1]> x > [1] -1.570796 > Browse[1]> cos(x) > [1] 6.123032e-17 > > I am not sure why I am getting one values when I am using a variable that > stores the value and another when I use the value directly. Am I missing > something here? > > Can someone comment? > > Thanks ../Murli > > ______________________________________________ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ 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.