oracle中的MOD和REMAINDER有什么区别? [英] What is the difference between MOD and REMAINDER in oracle?

查看:175
本文介绍了oracle中的MOD和REMAINDER有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管两个功能执行相同的操作,即使它们产生相同的o/p,这两个功能之间的基本区别是什么?是否存在与性能相关的差异,如果可以,那么哪个更好?

Although both the functions perform the same operation, even they produce same o/p, what is basic difference between these two? Is there any performance related difference, if yes, then which one is better?

谢谢

推荐答案

文档区别很明显:

注意

REMAINDER函数在其公式中使用round函数,而 MOD函数在其公式中使用了floor函数.

The REMAINDER function uses the round function in its formula, whereas the MOD function uses the floor function in its formula.

换句话说,当参数是正整数时,mod函数将返回一个介于0和第二个参数之间的正数.余数函数返回一个绝对值小于第二个参数除以2的数字.

In other words, when the arguments are positive integers, the mod function returns a positive number between 0 and the second argument. The remainder function returns a number whose absolute value is less than the second argument divided by 2.

负数之间的差异可能更大.差异的一个例子是:

The differences can be more striking for negative numbers. One example of a difference is:

REMAINDER(-15, 4)
MOD(-15, 4)

第一个给出-3,第二个给出1.

The first gives -3 and the second 1.

这是怎么回事? 4变成-15有多少次.一种方法是"-4"倍,余数为1.即:-15 = 4 *(-4)+1.另一种方法是"-3"倍:-15 = 4 *(-3)-3.

What is happening here? How many times does 4 go into -15. One method is "-4" times with a remained of 1. That is: -15 = 4*(-4) + 1. The other is "-3" times: -15 = 4*(-3) - 3.

以整数表示的-15/4之差.使用floor,您得到-4.使用回合,得到-3.

The difference what is -15/4 expressed as an integer. Using floor, you get -4. Using round, you get -3.

这篇关于oracle中的MOD和REMAINDER有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆