我有這樣的Java代碼來計算罪(360):正弦波360度是走出非零
if(re.equals(" sin "))
{
try{
String next=data.get(i+1);
v1 = Double.parseDouble(next);
double degreess = v1;
double radianss = Math.toRadians(degreess);
BigDecimal bDecimal1 = new BigDecimal(
Math.sin(radianss), MathContext.DECIMAL32);
re=""+bDecimal1;
//re=""+Math.sin(Math.toRadians(Double.valueOf(next)));
i++;
}
catch (Exception e) {
e.printStackTrace();
}
}
我希望sin(360)
應該正好爲0
但我的結果是非零: -0.0000000000000002449294
。爲什麼這不是零?
http://stackoverflow.com/questions/3961900/java-strange-behavior-with-sin-and-toradians 的http:// stackoverflow.com/questions/6566512/getting-value-of-sine-180-as-1-22465e-16 – 2013-03-07 13:26:45