[thelist] mod (%) help
Aaron Vegh
aaronvegh at gmail.com
Wed Jul 16 19:39:31 CDT 2008
>
> This is what i came up with but it fails on less than 8 due to
> adding 1.
>
> extrawheels = (wheelqty-4) + (wheelqty mod 4)
>
> anyone have a pointer?
4 mod 4 should give you 0. Not sure exactly where you're putting this
line of code in your logic, but you could try compensating by
subtracting one in this formula:
extrawheels = (wheelqty-4) + (wheelqty mod 4) -1
or I would do my logic this way:
if (wheelqty % 4 == 0) {
$wheel_discount = givediscount(wheelqty);
}
else {
$wheel_discount = 0;
}
Good luck!
Aaron.
More information about the thelist
mailing list