Modulo operator (%) for floats

Former Member
Former Member
Are there any way to get mod from float values?
  • Depending on what you want, you could just do a toNumber() and ignore the decimal part.

    If not, maybe something like this (untested code so there might be bugs)
    var a=123.456;
    var b=7.89;
    var mult=100000.0;

    var result= ((a*mult).toNumber()%(b*mult).toNumber())/mult;


    (there will be a max on the float value which can change by the multiplier)
    You take the float, and move the decimal point to the right, then treat that as an integer, do the mod, then move the decimal point back to the left.