Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculations with number of precision more than 16
Message
De
07/08/2001 09:28:28
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00540608
Message ID:
00540628
Vues:
15
>For those of you who need to perform calculations with precision better than 16 in VFP6 there is a new file YMORE16.exe to download from WWW.FOXITE.COM.
>
>YMORE16 works with positive and negative numbers written and stored as STRING.
>YMORE16 performs addition or subtraction on two numbers and returns the result as a STRING.
>Limits on number of decimals remain the same: maximum number of decimal places is 18 and the minimum is zero.
>
>Syntax examples:
>?ymore16("123456789012345.1234589", "+", "98765432109872345.1234589")
>?ymore16("+123456789012345.1234589", "", "-98765432109872345.1234589")
>?ymore16("-123456789012345.1234589", "-", "-98765432109872345.1234589")
>
>I will appreciate feedback with comments, opinions, bugs reports etc.
>
>Yuri Rubinov
>rubinov@juno.com

Yuri,

The basic idea is great - every now and then someone needs greater precision.

What does the second example do - the one with the empty operator?

I would suggest the following enhancements:

1) Extend the concept to multiplication and division. The algorithm is more complicated, of course, than addition or subtraction, and the calculations would be slow if you multiply, say, two 500-digit numbers. Ask me if you need details on the algorithm. The basic idea, of course, is to apply the multiplication algorithm you learned in primary school. Intermediate results have to be stored - and incremented - in arrays or something similar.

2) Instead of limiting to 16 decimals digits, you might provide an (optional) parameter for the number of digits in the result. Let's say that the default remains at 16 - this would seem a reasonable default to me. I mean, if you scan a text one byte at a time, there is no need to arbitrarily limit the input and the results to 16 decimals.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform