Re: [問題] 請問0.0 和-0.0

看板C_and_CPP作者 (ㄚ魚!!)時間11年前 (2012/11/09 10:10), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串4/4 (看更多)
總結一下 大家給的意見和小弟我試出來的結果 一句話來說就是 "VS2003 在輸出的部分 不合IEEE754規範" 借用james732的程式碼 http://ideone.com/vlWHPc 來看看變數的binary 跑出來的結果 VS2003: 10000000000000000000000000000000 a == 0.00 == 0 VS2008: 10000000000000000000000000000000 a == -0.00 == 0 看起來變數沒有問題 將值給入變數時 負號都有加上去 出問題的是在 "printf出來的時候" 這和azureblaze兄提供的連結內容http://ppt.cc/AHEu 一致 節錄部分: The VS 2003 version of printf outputs “0〃 for both -0 and +0, while the VS 2008 version of printf has been changed to output “-0〃 for -0. The reason is that VS 2003 was not compliant with the standard, so it was changed (starting with VS 2005) so that it’s now compliant. 感謝各位版友不吝提供意見 讓小弟在浮點數部分重新好好地複習了一下 改正不少觀念 謝謝大家m(o)m -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.112.106

11/09 17:28, , 1F
11/09 17:28, 1F

11/09 19:29, , 2F
你改過名字會讓別人沒辦法用[找到先前文章
11/09 19:29, 2F
※ 編輯: jokingfish 來自: 122.117.112.106 (11/12 09:39)
文章代碼(AID): #1Gd6O1Oy (C_and_CPP)
文章代碼(AID): #1Gd6O1Oy (C_and_CPP)