I have to make a Pi program to calculate to 30 000 decimal places in school but since I'm an idiot I can't go past 15 decimal places. Somebody help me please.
Hi VBidiot!<br>
<br>
A book every programmer should have is 'Practical Algorithms for Programmers' by John Binstock and John Rex. It contains algorithms for trees, linked-lists, sorting, searching, date/time functions, and arbitrary-precision arithmetic. It's written for C programmers, but you ought to be able to glean the concepts and use them in VB.<br>
<br>
The key to arbitrary-precision arithmetic is to declare two fixed-length strings. Decide some position to be the decimal point. Write functions to add, multiply, and divide (subtraction is a special case of addition) the individual positions of the string. So if you have stored:<br>
<br>
string A: 0 0 0 1 2 ^ 3 4<br>
string B: 0 0 0 0 9 ^ 0 0<br>
<br>
To add these, you would work your way right-to left, adding the columns and carrying as needed. Multiplication and division are left as exercises to the reader <grin>.<br>
<br>
Chip H.<br>
<br>
<br>
<br>
<br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.