Jump to content
  • Advertisement
Sign in to follow this  
Muncher

Float subtraction problem

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

Damn, ive seen some weird stuff, but this bug takes the cake. Im using C++, compiler is Studio.NET. i have two variables of type float x and y. with the following values (values are loaded from a file) x = 34.635418 y = 34.635422 if i subtract them i get: float res = x - y; wait for it..... res = -3.8146973e-006 WTF?! THE ANSWER SHOULD NOT BE -3!!!! I have tried different compilers, all get the same result. PLEASE HELP - i bet its something really simple too.... Paul [Edited by - felisandria on September 19, 2004 3:15:12 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
it's -3x10^-6

e.g.

0.000003 (give or take a zero)

swearing doesn't help your case.

Share this post


Link to post
Share on other sites
Welcome to scientific notation. You may have heard of it in all the high-school physics lectures you skipped.

Share this post


Link to post
Share on other sites
Err, it says the answer is -0.000038146973, or -3.8146973 * pow(10, -6), which is correct. 34.635418 - 34.635422 is -0.00003

Edit: Heh, love how when I started typing there were no messages, but when I post there's 2 more.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think he should just uninstall his compiler and come back when he can handle basic math.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravuya
Welcome to scientific notation. You may have heard of it in all the high-school physics lectures you skipped.
ROOFLELOLROTFLMAOHAHALOL!!!!1~

High school physics was useless anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by jjac7212
hey u guys, leave him alone.
he might be (like me) a young programmer who hasn't yet
done that math in school

Yes, but that does not justify swearing in the post topic, and one is much less likely to receive constructive help/comments if people do not approve of your post language.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!