• Advertisement
Sign in to follow this  

Function sin() in C

This topic is 3894 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

Im using this function from math.h, but it doesnt work properly, it doenst give a correct value, the varible im calculating the sin of is double, but i tried with float and long double, anyone has any idea what i have to do it?? Thank u

Share this post


Link to post
Share on other sites
Advertisement
It's returning the correct result, well, a close approximation of a correct result. Chances are you aren't passing it the correct value.

Share this post


Link to post
Share on other sites
What do you mean when you say it's not giving the correct value? Could you give an example of what you put in the function, what you expected it to return and what it actually returned?

Note, that sin (and all the goniometric functions in C) expect the input to be in radians, not degrees. To convert from degrees to radians, divide by (180 / PI).

Share this post


Link to post
Share on other sites
Yes u are right, i was giving the angle, so sin(90) said it was 0.82 or so, now i say sin(pi/2) and returns 1.0

Thank u

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement