C ++中100位数字的平方根 [英] Square root of a 100 digit number in C++
本文介绍了C ++中100位数字的平方根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
'unsigned long long'最多可解析15位数字.
'unsigned long long' can solve upto 15 digits.
是否可以找到 100位数字 的平方根?
Is there a way to find square-root of a 100 digit number?
推荐答案
您还可以使用 Boost.Multiprecision 库.该库为一些流行的多精度实现提供了包装.
You could also use Boost.Multiprecision library. This library provides wrappers for some popular multiprecision implementations.
#include <iostream>
#include <string>
#include <utility>
#include <boost/multiprecision/mpfr.hpp>
int main()
{
std::string s(100, '0');
s.at(0) = '1';
boost::multiprecision::mpfr_float_100 f(std::move(s));
boost::multiprecision::mpfr_float_100 sqrt = boost::multiprecision::sqrt(f);
std::cout << sqrt.str() << std::endl;
return 0;
}
这篇关于C ++中100位数字的平方根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文