Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Storing numbers like 1/3
Message
De
26/09/2006 17:50:01
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
26/09/2006 09:11:38
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01157137
Message ID:
01157366
Vues:
21
>>What's the best way to store numbers like 2/3, but in situations where you
>>do not want to do any rounding at all. Do you store 2/3 as a string?
>
>If you mean to store general fractions, I agree with Fabio, best thing to do is to store two integers. Maybe add some code to divide both with the largest common divider first. You may even write some code to do basic integer arithmetic with them - adding and multiplication. Depends on what do you want to do with them down the road.

Most code is already written. I would suggest FAQ #23746 for the simplification. (Find the greatest common factor with this FAQ, and divide numerator and denominator by this number.)
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
Répondre
Fil
Voir

Click here to load this message in the networking platform