This project is read-only.

To Modulo or not to Modulo?

Dec 13, 2010 at 3:09 PM

There has been some discussion as to the use of the percent symbol (%) and what it should represent in NeturalMath.  Traditionally in programming this has been used to represent modulus division, whereby the remainder of a division operation is returned from the operation.  There has been some concern that this may confuse non-programmer trained users who expect it to behave like a percent.  I would agree that this could be very confusing, and a true percent operation could be very useful for common operations.

The "r" operation has been suggested as one alternative.  Some systems also use the "mod" operation instead.  Another solution is to avoid inline-modulus altogether and just use a function instead.  Here are the various alternatives listed in code.  If anyone has any further ideas or preferences, please post them for discussion.

// as it is currently programmed
3 % 2

// using the "r" operator
3 r 2

// using the "mod" operator
3 mod 2

// using the "r" function

// using the "mod" function