Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numeric digits of precision
Message
De
05/03/2002 06:47:42
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00626806
Message ID:
00628287
Vues:
16
>Hilmar,
>
>>I don't expect accuracy to reduce when grouping digits. The point is that
>>VFP should take the same time to add 2 1-digit numbers, as to add 2
>>10-digit numbers. Therefore, the main loop should run 10 times faster,
>>without losing accuracy.
>
>I'm not comfortable being in the position of criticizing you because I don't want it to seem that I am ungrateful for your help. But I don't want you to lose sight of the fact that your functions are _already_ inaccurate. It says that 2^2 = 4.0000000027. That's not off by a degree of precision. That's just wrong - and the error is greater when working with larger numbers. I don't see the point in your effort to make your functions faster until they produce accurate results.

I will not make the .Power() method any more accurate, since you can get any desired degree of accuracy, simply by changing the number of decimals. I will, however, eventually post a class with a different method, .PowerInt(), for integral powers - based on repetitive multiplication instead of logarithm.

The same thing applies to the .Log() method - you can't trust the very last digits of the result, but you can make the error as small as desires, simply by calculating with more digits. I could make it calculate the result with more precision, but the results will never be completely trustworthy for your purposes. That is, the last digit shown might still be one off.

I don't think the .Log() method is the correct approach to work with an Ahnentafel.

>Now, I _could_ convert the whole numbering system to a binary decision tree (where 0 represents a father and 1 represents a mother at each intersection), if that is what you are suggesting. Then I could (a) use functions like yours to do a lot of calculations each time I need to represent the number to the user in the format above that they understand and (b) I could easily compare the two nodes without logarithms to determine if the are in the same line. But then to calculate the number representing the father of a person in the 53rd generation, I'd need to do exponentiation on a 30+ digit _binary_ number. I don't see how the net result is any easier, faster, or better.

Where would you need exponentiation? You don't need exponentiation to convert from binary to decimal, if that is what you mean. By using the shortcut conversion, you would be using only multiplications and additions, and those are completely accurate for integers.

I believe you could store all results in binary, do comparisons in binary (which, if I understand correctly, doesn't require logarithms), and only convert to decimal to show the number to the user.

>Once again, I've found C++ libraries which do exactly what I want <g> (do exponentiation and logarithms on 100+ digit numbers without errors and return the result as a string). Now I just need to find someone to convert them to a Windows DLL so that I can access from VFP.

If you can make them work, they will be much faster than anything that can be written in VFP - as David Frankenbach already mentioned.
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