Dividend. Any real positive or negative value, or zero.
Divisor. Any real positive or negative value, not zero.
The fmod() function returns the floating point remainder (modulo) of the quotient of its arguments as a number. With the notation that represents the value of x floored towards zero, for example and , the corresponding mathematical notations is:
Use the calculator at the top right to find the modulo of two numbers. Click the [2nd] key at the top left of the keypad.
Sometimes, the fmod() function returns erroneous results, for example fmod(2,0.4) returns 0.4 instead of 0 (see the examples below). Using Formulas built-in functions, the fmod() function can be defined as:
Tip: The above code seems to work better than the fmod() function.
Modulo on calculators
When x or y is negative, the value returned by fmod() may differ from the value obtained on a calculator that uses the regular floor function , for example and , to calculate the modulo:
x modulo y
Note:x floored towards zero, , and x floored in the ordinary way, , are different values. For example, and .
-15 Google calculator: 5 TI-Nspire CX CAS: 5 WEB 2.0 CALC: 5
15 Google calculator: -5 TI-Nspire CX CAS: -5 WEB 2.0 CALC: 15 (?)
Error Google calculator: No result TI-Nspire CX CAS: 7 WEB 2.0 CALC: Error Division by zero
Evaluation error (division by zero)
0.4 Wrong: it should be 0 Google calculator: 0 TI-Nspire CX CAS: 0 WEB 2.0 CALC: 0
This error is due to a bug in the regular PHP library. This bug was reported 13 years ago in PHP.net by jphansen uga edu.
Use the calculator below to find the modulo of two numbers (click the 2nd key at the top left of the keypad). Note that the value obtained with the calculator may differ from the value returned by the fmod() function:
Type 35 modulo -20 (35 mod -20 and 35 % -20 are also accepted) in the search box of the Chrome or Firefox browser, and the Google calculator will appear with the answer: