`
happmaoo
  • 浏览: 4334409 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Oracle Remainder函数与Mod函数的区别

阅读更多

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)
----------

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics