I am reading the manual (type 'man round' in the terminator) of round for Greedy and I don't understand exactly why I should use round. I see it is rounding up a float to a integer. But I don't want an integer in Greedy right? I want a 2 decimal number like 0.35... Can someone tell me.. Did I understand round wrong?


You understand the round function correctly, it does round a float to the nearest whole number.

The point of the exercise is to understand how floats are stored in the computer and how to adapt to the situation. In this case, you're starting with a two digit decimal float that represents dollars and fractions of dollars and need to ultimately work with something that is pure whole numbers, or integers. Think about that, and think about all the types of coins that you will be working with.

I would suggest that you review all the class material from the week and the pset assignment.

If this answers your question, please click on the check to accept. Let's keep up on forum housekeeping. ;-)

  • Ok. So I understood it right. But the other part of my question was.. If the round function is rounding the float up to an integer. Why should I use it in Greedy?
    – LvdD
    Sep 28 '15 at 15:23
  • Well, I could tell you in very simple terms, but that's the whole point of the assignment - to figure out how and why to use the round function. Were it not for that, I'd be happy to share. But I'll drop another hint. If rounding in dollars isn't going to help, can you convert dollars to something else? That and the subtle hint in my answer should be enough.
    – Cliff B
    Sep 28 '15 at 17:12
  • Thanks for the tip! Finally I understood the point about using round. :)
    – LvdD
    Sep 29 '15 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .