Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Storing numbers like 1/3
Message
From
26/09/2006 17:50:01
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
26/09/2006 09:11:38
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01157137
Message ID:
01157366
Views:
20
>>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)
Previous
Reply
Map
View

Click here to load this message in the networking platform