Modulus division returning 1 less than it should [Answered]
when i assign change, its equal to 0.95. it should return 5, but this is returning 4? shouldnt it be returning 5?
10 Replies
That's looks like a good way to get hurt by rounding errors
idk what that means, but im doing this for a compsci project lol
its supposed to calculate how many pennies when you input change
Better learn about why 0.1 is not nice for computers/floating point representation then
Advise not using double or float for simple money projects tbh
yeah but the teacher is telling me to
what should i do
Lol
im rly new to compsci lol
i just did math.round so im gonna assume this works lol
so like
and it works
so like
yuhh
Yeah
(int) just truncates
alr lol
If you use math. Round with someone's money you go to jail tho lol
✅ This post has been marked as answered!