This silly scripting language doesn't have a % or Mod(). I do have a Fix() that chops off the decimal part of a number. I only need positive results, so don't get too robust.
+7
A:
Will
// mod = a % b
c = Fix(a / b)
mod = a - b * c
do? I'm assuming you can at least divide here. All bets are off on negative numbers.
John Källén
2010-05-03 23:55:53
A:
This may not work for you performance-wise, but:
while (num >= mod_limit)
num = num - mod_limit
tloflin
2010-05-03 23:56:24
@tloflin, hope you don't mind but it should have been ">=" rather than ">".
paxdiablo
2010-05-04 00:00:43
@paxdiablo, true, thanks.
tloflin
2010-05-04 00:03:37
by not working performance-wise, did you mean like when num is around 2**63 and mod_limit is 3?
GregS
2010-05-04 00:05:52