Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining the number of decimal places of a variable?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00759689
Message ID:
00759696
Vues:
19
This message has been marked as the solution to the initial question of the thread.
>Does anyone know of a way to determine the number of decimal places of a numeric variable or of a way to return the correct number of decimals as a String?
>
>I can't find a function to determine how many decimals are stored in the variable.
>
>for example:
>
>
>
>n = 20.000
>? n            && returns 20.000
>? TRANSFORM(n) && Returns 20
>
>
>
>
>I'm feeling pretty stupid not be able to figure this one out.

You could do:
cN = ALLTRIM(PADR(n,20))
nDecimal = RAT(".",cN)
or combine into one statement:
nDecimal = RAT(".",ALLTRIM(PADR(n,20)))
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform