您的位置:首页 > 数据库 > Oracle

Oracle Remainder函数与Mod函数的区别

2009-09-21 10:15 337 查看
REMAINDER returns the remainder of the 1st argument divided by the 2nd argument.

Remainder is similar to MOD except thaqt REMAINDER uses ROUND in its calculations, whereas MOD uses FLOOR
在用round(n1,n2)和mod(n1,n2)函数在进行运算时,都用了一个公式result=n2-(n1*N);N=n2/n1;
而在remainder(n1,n2)函数中,N=round(n2/n1),在mod(n1,n2)函数中N=floor(n2/n1);
例如:

SQL> select remainder(3.5,2) from dual;

REMAINDER(3.5,2)
----------------
-.5

SQL> select mod(3.5,2) from dual;

MOD(3.5,2)
----------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: