Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert Fractions to Decimal
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476506
Message ID:
00476643
Vues:
29
Well. It is not that easy to go from decimal to fraction. Because 1/2 = 0.5 = 2/4 = 4/8, etc. So if you have 0.5 how do you know which fraction is the correct one?

But what you could do is:
lnCnt = 0
lnDec = 0.6
do while .T.
  lnCnt = lnCnt + 1
  lnResult = lnCnt * lnDec
  if lnResult == int(lnResult)
    exit
  endif
enddo

? "Fraction: " + allt(str(lnResult))+"/"+allt(str(lnCnt))
That should give you the first fraction met.

HTH,
- Erik Niese-Petersen

Crazy Dane in USA.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform