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:
00476759
Vues:
34
Hey George

I don't know if this is the best way to calculate it but it works!
LPARAMETER lcString
LOCAL i, lnNum, lnDom, lnMax, lnDecimal
lnMax = 64
lnNum = 1
lnDecimal = VAL(lcString)
* Decimal part only
FOR i = 1 to lnMax
  lnNum = lnDecimal * i
  IF ROUND(lnNum,0) == lnNum
    lnDom = i
    EXIT
  ENDIF
ENDFOR
RETURN ALLTRIM(STR(lnNum)) + "/" + ALLTRIM(STR(lnDom))+["]
All I have to add is the part to round it out if it falls outside of the lnMax range...

What do you think??
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform