0

I understand that certain numbers can't be represented as a floating point value, but is there another way to correct this if it affects my analysis?

> a<-6.959435821 
>
> sprintf("%5.25f", a)
[1] "6.9594358209999995779071469"
Randy C.
  • 1
  • 1
  • 6
    https://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal – rawr Nov 14 '17 at 23:20
  • You might have a legitimate new question here, but I can't really tell. How is this affecting your analysis? What output are you hoping for? It looks like you had a number with 9 decimal places of precision, and asked R to print it with 25 decimal places of precision. The output is consistent to the 9 decimal places you specified. What else do you expect? – Gregor Thomas Nov 15 '17 at 14:52
  • The analysis is incorrect because this is only one of the 5 regression coefficients I use to predict the dependent variable over multiple years. The other 4 coefficients are multiplied by X, X^2, X^3 and X^4 respectively. The change in the stored value makes a small but noticeable difference in the final number. – Randy C. Nov 16 '17 at 14:34

0 Answers0