看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) win7 64bit 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) VC2005 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 使用math.h的sqrt(),但回傳值錯誤,ex:sqrt(25.0)=1057620607 不過如果把sqrt()再包過一層,其回傳值就會正確,ex:fsqrt(25.0)=5 餵入的資料(Input): 25 預期的正確結果(Expected Output): 5 錯誤結果(Wrong Output): 1057620607 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) double fsqrt(double x) { return sqrt(x); } 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.96.32.110 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1527133241.A.7E2.html
LPH66: 只貼"正確"的 fsqrt 我們根本不知道你"錯誤"的 sqrt 怎麼錯 05/24 14:44
god145145: compiler選錯程式 05/24 14:48