[問題] sqrt回傳值錯誤

作者: newlymoon (NEWLYMOON)   2018-05-24 11:40:38
開發平台(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):
作者: LPH66 (-6.2598534e+18f)   2018-05-24 14:44:00
只貼"正確"的 fsqrt 我們根本不知道你"錯誤"的 sqrt 怎麼錯
作者: god145145   2018-05-24 14:48:00
compiler選錯程式

Links booklink

Contact Us: admin [ a t ] ucptt.com