annoying rounding problems...

i have made a program and its output is sometimes something like 1.0000005 . that's pretty annoying but i can get it solved with some rounding. but when my answer should be 1.3333333 for example i also get the precision problem and i get like 1.333333339 . i can't use a simple round to solve this so could anyone tell me how to get the right value?
I don't think there's an easy answer. But judging by the examples quoted, your results have limited precision. I'd recommend using double or long double, which should be better than float. But that merely pushes the problem further along into the later digits.
Last edited on
Please read this. There is no easy solution to your problem. You can use less precision (print less digits after period) so 1.333333339 will become 1.333333

EDIT: sin(1.0) is equal sin(1.0)? Do you really think so?
Last edited on
hmm ok thank you
Topic archived. No new replies allowed.