… | |
… | |
595 | } |
595 | } |
596 | |
596 | |
597 | for (i = 0; i < NUM_COINS; i++) |
597 | for (i = 0; i < NUM_COINS; i++) |
598 | { |
598 | { |
599 | object &coin = *coin_objs[i]; |
599 | object &coin = *coin_objs[i]; |
600 | sint64 num_coins = min ((to_pay + coin.value - 1) / coin.value, coin.nrof); |
600 | sint64 num_coins = min ((to_pay + coin.value - 1) / coin.value, (sint64) coin.nrof); |
601 | to_pay -= num_coins * coin.value; |
601 | to_pay -= num_coins * coin.value; |
602 | |
602 | |
603 | coin.nrof -= num_coins; |
603 | coin.nrof -= num_coins; |
604 | /* Now start making change. Start at the coin value |
604 | /* Now start making change. Start at the coin value |
605 | * below the one we just did, and work down to |
605 | * below the one we just did, and work down to |