Menu

#13 Modulus function

open
nobody
Functions (18)
1
2007-02-03
2007-02-03
Anonymous
No

Many times I have needed the ability to find the remainder of a division problem. While it can be done with a while loop or some tricky scripting, I feel this mathematical operation could be done much more smoothly with MWSE

Submitted by Jeoshua@gmail.com

Discussion

  • Grant McDorman

    Grant McDorman - 2007-02-03
    • priority: 5 --> 1
     
  • Grant McDorman

    Grant McDorman - 2007-02-03

    Logged In: YES
    user_id=178930
    Originator: NO

    No while loop or tricky scripting is required; simple integer arithmetic in two statements will give you the remainder:
    long quotient
    long remainder
    set quotient to (value/divisor)
    set remainder to (value-quotient*divisor)
    Although I have not tested it, even this may work (provided all values being used are integer):
    set remainder to (value-(value/divisor)*divisor)

     

Log in to post a comment.

MongoDB Logo MongoDB