Topic: 帮帮我吧 - 求余数问题(Math.IEEEremainder)

  Print this page

1.帮帮我吧 - 求余数问题(Math.IEEEremainder) Copy to clipboard
Posted by: 198255nihao
Posted on: 2006-01-18 00:38

请问 :
System.out.println(Math.IEEEremainder(a,10));
前提是a>=0且a<10 int类型
为什么 a <=5的时候 求出的结果为a
当 a>5 的时候求出的结果为负数呀

2.Re:帮帮我吧 - 求余数问题 [Re: 198255nihao] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 02:26

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#IEEEremainder(double,%20double)
The remainder value is mathematically equal to f1 - f2 × n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even.

a < 5 :
n = 0 is the mathematical integer closest to the exact mathematical value of the quotient a / 10
The remainder value is mathematically equal to a - 10 × 0 = a

a == 5 :
two mathematical integers are equally close to 5/10, then 0 is the integer that is even.
The remainder value is mathematically equal to 5 - 10 × 0 = 5

a > 5 :
n = 1 is the mathematical integer closest to the exact mathematical value of the quotient a / 10
The remainder value is mathematically equal to a - 10 × 1 为负数


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923