當我使用ATAN函數從CMATH和數學上的一個浮點數,我似乎得到不同的答案:CMATH和math.h中給出不同的答案
#include <cmath>
#include <math.h>
#include <iostream>
#include <iomanip>
int main() {
std::cout << std::setprecision(20) << atan(-0.57468467f) << std::endl;
std::cout << std::setprecision(20) << std::atan(-0.57468467f) << std::endl;
// I get:
// -0.52159727580733605823
// -0.52159726619720458984
}
爲什麼會出現這種情況?兩個庫有不同的執行方式嗎?
我願意賭一個人必須把它轉換成雙。 – chris
您正在使用哪種編譯器? –
我正在使用g ++ 4.7 – Peter