2016-10-30 173 views
6

的boost ::多倍::开方(1)似乎返回0为什么Boost :: multiprecision :: sqrt(1)返回0?

#include <boost/multiprecision/cpp_int.hpp> 
#include <boost/multiprecision/number.hpp> 
#include <iostream> 

using std::cout; 
using std::endl; 

int main() { 
    namespace mp = boost::multiprecision; 
    mp::cpp_int i(1); 
    cout << "i == " << i << endl; 
    cout << "mp::sqrt(i) == " << mp::sqrt(i) << endl; 
} 

输出:
我== 1
MP ::开方(I)== 0

我期待sqrt(1)== 1.

我在coliru和我的本地安装中使用gcc和Boost 1.62获得了相同的结果。这是否发生在别人身上?我错过了什么或者这是一个错误?

+0

Eeerm,你还期望什么? –

+5

我希望sqrt(1)== 1 – Chad

+0

这看起来像一个错误100%,对边缘案例的测试非常差。 http://coliru.stacked-crooked.com/a/068a750da56b55d1 – stefan

回答

5

是的,这绝对是一个错误。 3天前向Boost bug跟踪器报告为ticket #12559

+0

谢谢!不知道我在错误跟踪器中错过了这些。 – Chad

相关问题