Problem regarding cmath header

I have a project currently using cmath header for cos(x) and sin(x) functions. all variables are float. currently, i have a problem of "too high" precision.

is there anyway to solve the problem? like keeping 3 or 4 digits after decimal and ignore the rest.

or is there any C++ libraries that can do this?

thanks for anyone answering ahead.
Last edited on
no, not the print check.

i mean actual variable precision.

there are places in the program that after a combination of cos, sin permutations, the value is supposed to be 0 mathematically but is stored as an extreme small value instead of actual 0.

well, this is basically what i'm trying to solve here.
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
Round errors and machine precision make that impossible, at least you operate symbolically.

That's why you should not use operator== with floats, but
fabs( a-b ) < tol
Topic archived. No new replies allowed.