I used n = 100.0*n; float roundf(float n); to covert dollar to cent and round it. However when I use gdb with an input of 4.2, the converted n is 419.999... and the program yields a result of 22 instead of 18. Why my round doesn't work?
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community