Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding and Subtracting large numbers
Message
 
 
À
25/09/2019 11:16:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01671113
Message ID:
01671118
Vues:
50
>>>>I am struggling implementing a code that would be able to add large numbers. Basically it is working, I am using the Math_unlimited.vcx from the download section. However once the result would be negative it gives wrong results. I would need to rewrite the code, but I was wondering if someone has a better code for this, or perhaps even an fll solution that could be used instead?
>>>
>>>How big of numbers do you need?
>>>
>>>I wrote an open source arbitrary precision math library that used MPFR several years ago in C/C++. It could be ported to an FLL with little difficulty. It provided basic trig functions, exponents, roots, etc.
>>>
>>>UPDATE: In fact, in thinking about it, I think I wrote a VFP wrapper at one point. Hmm...
>>
>>I have numbers that come close to 20 digits, no decimals, but could get negative. Actually it's for calculating hash codes for bank files, which is a relatively general task.
>
>I found the code. I don't remember what state it's in. You can look at it and test it. See attached.
>
>The way it works is you allocate a number inside the bignum.dll. It returns an id or handle. You use that handle to reference the number performing functions on it. When you're done, use the to_*() methods to retrieve the value.
>
>The maximum precision most computers can handle is from an 80-bit real, which is 17-18 decimals of precision in base-10. For ~20 you need to use a fixed integer most likely, and there probably are other libraries which are better for those kinds of calculations. As I recall, bignum would use the size you allocate in the new() method.
>
>new() -- Allocate a number
>free() -- Release it when you're done
>to_*() -- Retrieve the value into VFP

Great, thanks a lot, I will review it and see if I can implement it.
Christian Isberner
Software Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform