爲什麼是下面的代碼的輸出:
for (float j2 = 0.0f; j2 < 10.0f; j2+=0.1f) {
System.out.println(j2);
}
此:
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.70000005
0.8000001
0.9000001
1.0000001
1.1000001
1.2000002
1.3000002
1.4000002
1.5000002
1.6000003
1.7000003
1.8000003
1.9000003
2.0000002
2.1000001
2.2
2.3
2.3999999
2.4999998
2.5999997
2.6999996
2.7999995
2.8999994
2.9999993
3.0999992
3.199999
3.299999
3.399999
3.4999988
3.5999987
3.6999986
3.7999985
3.8999984
3.9999983
4.0999985
4.1999984
4.2999983
4.399998
4.499998
4.599998
4.699998
4.799998
4.8999977
4.9999976
5.0999975
5.1999974
5.2999973
5.399997
5.499997
5.599997
5.699997
5.799997
5.8999968
5.9999967
6.0999966
6.1999965
6.2999964
6.3999963
6.499996
6.599996
6.699996
6.799996
6.899996
6.9999957
7.0999956
7.1999955
7.2999954
7.3999953
7.499995
7.599995
7.699995
7.799995
7.899995
7.9999948
8.099995
8.199995
8.299995
8.399996
8.499996
8.599997
8.699997
8.799997
8.899998
8.999998
9.099998
9.199999
9.299999
9.4
9.5
9.6
9.700001
9.800001
9.900002
還有一個問題:即使我將for循環的條件更改爲j2<=10.0f
的輸出也是一樣的。爲什麼這樣?它不應該包含10.0
的輸出嗎?
你說的O/P是什麼意思?如果你的意思是「輸出」,請輸入單詞 – Nanne 2012-02-17 09:59:48
是o/p =輸出。爲您更新。 ; p – 2012-02-17 10:01:24
可能是一個精確的錯誤。 – 2012-02-17 10:02:03