class Test {
public static void main(String[] args) {
int big = 1234567890;
float approx = big;
System.out.println(big - (int)approx);
}
}
上記のコードは Java 言語仕様から取得しました。私の疑問は、正しい答えを得るための可能な方法があるということです。strictfp を使用しましたが、同じ結果が得られました (以下のコードを参照)。
strictfp class Test6 {
public static void main(String[] args) {
int big = 1234567890;
float approx = big;
System.out.println(big - (int)approx);
}
}
これは を出力します-46
。