[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfriends:00180] Re: 切り上げと切り捨て





> Math#round は四捨五入ですよね。

見事に罠にかかってます。

Math#round はこんな実装になっていますが、

    public static long round(double a) {
	return (long)floor(a + 0.5d);
    }

これは負の数に対して、四捨五入となるでしょうか?

-- 
/** 久野 浩 - Hiroshi Kuno
 * @email       mailto:hkuno@xxxxxxxxxxxxxxxx
 * @interesting ISO C99(9899:1999), ISO C++(14882:1998), Java and astronomy
 */