Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining the number of decimal places of a variable?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00759689
Message ID:
00759696
Views:
20
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform