Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I have math functions go beyond 15 decimal places? 1

Status
Not open for further replies.

VBidiot

Programmer
Sep 28, 1999
1
CA
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 &lt;grin&gt;.<br>
<br>
Chip H.<br>
<br>
<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top