3 ms·
Assuming truncating division: Round down: discount = 33 value / 100; Round up: discount = (33 value + 99) / 100; Round to nearest: discount = (33 value +
by andyv 16y ago
Assuming truncating division:
Round down:
discount = 33 value / 100;
Round up:
discount = (33 value + 99) / 100;
Round to nearest:
discount = (33 value + 50) / 100;
- count 16y agoBut which method is appropriate for financial code?
- abeld 16y agoI would use whichever errs in favor of the customer. Its only one cent, after all.
- mooism2 16y agoIf full price is £9.99 and you've got it on offer at £5.00, that's less than 50% off. If you want to say you're offering it at 50% off, you need to price it at £4.99. In banking, I believe the convention is to round to the nearest penny, and round half-pennies to the nearest even penny.
- andyv 16y agoOh, sorry. I would say that selecting the rounding policy is up to you. I'd agree with the poster that gives the fractional penny to the customer.