Search code examples
modulorokubrightscript

How can I do mod without a mod operator?


This 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.


Solution

  • 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.