1
一個簡單的問題有兩行代碼最好問:花車和整數簡單的問題
CGFloat answer = (abs(-27.460757f) - 9.0f) * (800.0f/(46.0f - 9.0f));
NSLog(@"According to my calculator, answer should be 399.15, but instead it is: %f", answer);
當我在Xcode中運行這個(具體而言,在iPhone模擬器),我得到:
根據我的計算,回答 應該是399.15,但取而代之的則是: 389.189209
這僅僅是因爲我缺乏understan的如何浮動圓形?
謝謝!
斯圖爾特
謝謝!我知道這會很簡單。 – smacdonald 2011-02-18 12:35:02