越南人评中国象棋:求助开方的高精度算法(用vb6.0的语言),谢谢了!!

来源:百度文库 编辑:中科新闻网 时间:2024/05/09 19:23:56
求助开方的高精度算法(用vb6.0的语言),谢谢了!!
如sqrt(2):
#include <iostream>
#include <cryptlib/integer.h>
#include <sstream>
using namespace std;
using namespace CryptoPP;

#define PREC 1000

int main( int argc , char* argv[] )
{
if( argc != 2 )
{
cout << "usage foobar <number>" << endl;
exit( 1 );
}

istringstream iss( argv[1] );
Integer nn , mm = 1 , mm2; iss >> nn;

for( int i = 0; i < PREC; ++i ) mm *= 10; mm2 = mm * mm; nn *= mm2;
cout << nn.SquareRoot() << endl;
}
得:
1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727350138462309122970249248360558507372126441214970999358314132226659275055927557999505011527820605714701095599716059702745345968620147285174186408891986095523292304843087143214508397626036279952514079896872533965463318088296406206152583523950547457502877599617298355752203375318570113543746034084988471603868999706990048150305440277903164542478230684929369186215805784631115966687130130156185689872372352885092648612494977154218334204285686060146824720771435854874155657069677653720226485447015858801620758474922657226002085584466521458398893944370926591800311388246468157082630100594858704003186480342194897278290641045072636881313739855256117322040245091227700226941127573627280495738108967504018369868368450725799364729060762996941380475654823728997180326802474420629269124859052181004459842150591120249441341728531478105803603371077309182869314710171111683916581726889419758716582152128229518488472...