Calculate the circularity Pi (π) value, accurate to 10,000 in the decimal point

zhaozj2021-02-16  62

[Recommended] Calculate the circularity PI (π) value, accurate to the decimal point of 10,000 accurate to 1000 bits after the decimal point: On the form, put a button button 2, on this button on the onclick event write: void __fastcall tform1 :: Button2click (TOBJECT * sender) {const arrsize = 1010, Dispcnt = 1000; // Defines an array size, display bit char x [arrsize], z [arrsize]; // x [0] x [1]. X [2] X [3] x [4] .... x [arrsize-1] int A = 1, b = 3, C, D, Run = 1, CNT = 0;

MEMSET (X, 0, Arrsize); MEMSET (Z, 0, Arrsize);

x [1] = 2; z [1] = 2;

While (Run && ( CNT <200000000)) {// z * = a; d = 0; for (int i = arrsize-1; i> 0; I -) {c = z [i] * a D; z [i] = c% 10; D = C / 10;} // z / = b; D = 0; for (int i = 0; i 0; I -) {c = x [i] z [i]; x [i] = c% 10; x [i-1] = C / 10; Run | = z [i];} a ; b = 2;} Memo1- > Text = Ansistring (). Sprintf ("calculated% D times / R / N", CNT); Memo1-> text = MEMO1-> Text Ansistring (). Sprintf ("pi =% D% d. / R / N ", x [0], x [1]); for (int i = 0; i text = MEMO1 -> Text "/ r / n"; MEMO1-> text = MEMO1-> Text (int) x [i 2];}}

Perform results by button2:

Pi = 03.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164 201989 This psychology has, is it possible to change the number of digits? The answer is yes. If the defined array size and display bits are changed to:

Const arrsize = 10100, Dispcnt = 10000; // Define an array size, display bit

The execution result accuracy can reach 10,000:

Pi = 03.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164 2019893809525720106548586388865936153381827968230301957773852998995773625994138917367259948389124972177528347913151 ... limited to space, here is omitted, or leave you yourself!

50201410206723585020072452256326513410559240190274216248439140359989535394590944070469120914093870012645600162374288021092764579310657922955249887275846101264836999892256959688159205600101655256375678

Improve the principle of accuracy:

The principle of the above procedure is to use the array to save the calculation results, where each of the arrays, one of the number of items, the decimal point is positioned between the first number and the second number of arrays, that is, the front 2 digits, The rest is a small number.

Using the computer to simulate the sum of four computational description methods to achieve high-precision data calculations, the most precise method did not expect the most accurate precision.

转载请注明原文地址:https://www.9cbs.com/read-16984.html

New Post(0)