奇怪的取余数

[复制链接]
查看11 | 回复9 | 2012-5-21 10:19:41 | 显示全部楼层 |阅读模式
SQL> exec dbms_output.put_line(8 mod 3)
2
SQL> exec dbms_output.put_line(remainder(8,3))
-1
SQL> exec dbms_output.put_line(8 remainder 3)
-1
SQL> exec dbms_output.put_line(8 rem 3)
2
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
这是什么语法,求科普
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
pl/sq中可以把取模符号放在2个操作数中间
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
MOD的算法好像是MOD(A,B) = A - B*FLOOR(A/B);
REMAINDER算法是REMAINDER(A,B) = A-B*ROUND(A/B);
但是dbms_output.put_line中的写法不懂啊,求解释。
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
新鲜啊
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
REMAINDER这函数第一次用,学习了
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

回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
rem和mod一样??
???remainder是If n1 != 0, then the remainder is n2 - (n1*N) where N is the integer nearest n2/n1.
If n2/n1 equals x.5, then N is the nearest even integer.
8-(3*3)=-1
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
rem和mod一样?
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
helonten 发表于 2013-10-28 09:47
MOD的算法好像是MOD(A,B) = A - B*FLOOR(A/B);
REMAINDER算法是REMAINDER(A,B) = A-B*ROUND(A/B);

还基本真是,除了round为.5的时候到两端距离一样,所以规定出了一个值
If n1 != 0, then the remainder is n2 - (n1*N) where N is the integer nearest n2/n1.
If n2/n1 equals x.5, then N is the nearest even integer.
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
哈哈,学习了。。。。remainder 跟我们平常的取余不一样,所以估计不常见了。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行