This was tested on Oracle 11.1.0.6.0 running on Windows XP. The mod function calculates the remainder when you divide the first value by the second:
SQL> select mod(10,7) from dual;
MOD(10,7)
----------
3
SQL> select mod(-11,6) from dual;
MOD(-11,6)
----------
-5
SQL> select mod(9,-5) from dual;
MOD(9,-5)
----------
4
SQL> select mod(-8,-3) from dual;
MOD(-8,-3)
----------
-2
SQL>
The numbers do not have to be integers:
SQL> select mod(4,1.5) from dual;
MOD(4,1.5)
----------
1
SQL> select mod(6.2,3) from dual;
MOD(6.2,3)
----------
.2
SQL>
... but I was a bit surprised that the next calculation did not return a division by zero error:
SQL> select mod(2,0) from dual;
MOD(2,0)
----------
2
SQL>
No comments:
Post a Comment