Sign in to follow this  

[C++] math.h sin(M_PI) problem.

This topic is 2842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quote:
Original post by WindScar
It's returning a weird number that's not zero. What's wrong?
Probably just a precision issue. Can you post the number that you're getting?

[Too slow...]

Share this post


Link to post
Share on other sites
Quote:
Original post by WindScar
It seems a bit weird to have such a small number in my console instead of 0, but I suppose that's too small to be a problem. Thank you.


Well, it's too small to be a problem unless you're doing things like testing thingThatShouldBeZero == 0 and getting strange bugs as a result (in case it's not clear, you should test for thingThatShouldBeZero < epsilon). Floating point computation has lots of gotchas that are well worth learning about. If you're just worried about pretty-printing, use setprecision to cut it off at a sensible point.

Share this post


Link to post
Share on other sites

This topic is 2842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this