Search:
Forum
General C++ Programming
My program don't add up ? Eg 0.5+0.2+0.2
My program don't add up ? Eg 0.5+0.2+0.2+0.1 not equal to 1
Aug 22, 2010 at 3:57pm UTC
DeathYu
(1)
Problem Solved!!! Thanks for helping guys
Last edited on
Aug 23, 2010 at 2:00pm UTC
Aug 22, 2010 at 6:37pm UTC
ne555
(10692)
if
(total_User_pay==1)
You shouldn't compare equalities with double or float type data.
The binary representation it's not exact, you've got trunc error. Instead of 1 you get 0,99999.
Use an epsilon to compare, round your number or try to work with integers
Last edited on
Aug 22, 2010 at 6:38pm UTC
Aug 22, 2010 at 6:45pm UTC
ne555
(10692)
Also
avoid using goto.
main must return int.
when posting code, please use code tags
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs