Jump to content
  • Advertisement
Sign in to follow this  
suliman

cos gives strange results

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

Hi u->angle=90.0; float pop=-cos(32*12.3455*u->angle); float slope=-cos(u->angle* 3.1415926535897932384626433832795 / 180.0); --------------------- pop and slope becomes: -0.0641614 4.37114e-008 ------------------- Why is this? Is the value in slope corrupted? If i mult with 100 and cast to int slope is 0 while pop is -6. Thanks Erik

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Fist it was your “My awesome game” post and then your “About boring jokes (my awesome game)” post and now this. Obviously all results are correct. So why do you waste the time of people that are here to help?

Share this post


Link to post
Share on other sites
Quote:
Original post by suliman
Why is this?


Floating point numbers have limited precision.

Quote:
Is the value in slope corrupted?


The difference between 4.4e-8 and 0 isn't that great.

Quote:
If i mult with 100 and cast to int slope is 0 while pop is -6.


4.4e-8 is 0.000000044

Share this post


Link to post
Share on other sites
Quote:
Original post by suliman
pop and slope becomes:
-0.0641614
4.37114e-008

-------------------

If i mult with 100 and cast to int slope is 0 while pop is -6.

If you cast that float to int then it will equal 0. Going from float to int usually drops the decimals. :/ Also for future reference the "e" in a number like that usually means scientific notation.

Share this post


Link to post
Share on other sites
Ah i think i get it now. But it's a bit confusing that the compiler mix different modes of representation. Anyways thanks for clearing it out.

@Anonymous Poster
How is this in ANY way related to the "my awesome game" tread? Im sorry if i offended you with that atrocity but please inject some self-distance. Or at least stop posting as anonymous.

Erik

Share this post


Link to post
Share on other sites
i think i have never really dealt (conciensely) with those e-00X numbers. It all make sense when reading the stuff recommended by you guys. As often, these calculations failed becouse of another change i made earlier. Thats why i though it was corrupt.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Fist it was your “My awesome game” post and then your “About boring jokes (my awesome game)” post and now this. Obviously all results are correct. So why do you waste the time of people that are here to help?


This is the beginner's forum. People frequently ask questions with answers that are obvious to others. That is the purpose of this forum, so I wouldn't waste my time flaming people for it.

Share this post


Link to post
Share on other sites
Quote:
Original post by JohnBolton
This is the beginner's forum. People frequently ask questions with answers that are obvious to others.


And the poster responsible for this anonymous flame has been suspended. Such behaviour is not tolerated in For Beginners.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!