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:
00476779
Vues:
28
Hey George

Her is one that I think is better...
LPARAMETER lcString
LOCAL lnNum, lnDom, lnMax, lnDecimal, lnPower
lnMax = 64
lnNum = 1
lnDom = 2
lnPower = 1
lnDecimal = VAL(lcString)
* Decimal part only
DO WHILE lnDom <= lnMax
  lnDom = 2^lnPower
  lnNum = lnDecimal * lnDom
  IF ROUND(lnNum,0) == lnNum
    EXIT
  ENDIF
  lnPower = lnPower + 1
ENDDO
RETURN ALLTRIM(STR(lnNum)) + "/" + ALLTRIM(STR(lnDom))+["]
Still need to take into consideration rounding for a generic function

TGIF

Thank George it's Friday
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform