Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decimal precision is of a variable
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00136301
Message ID:
00136695
Views:
26
>Is there a command that returns the decimal precision of a variable?
>
>Example a=1.00 is 2 decimal
> a=1 is 0
>
>TIA

Try following function

FUNCTION LenDecimals
LPARAMETER tnTestNum
LOCAL lcNumber, lnPos, lnResult

lcNumber = LTRIM( PADL( tnTestNum, 99))
lnPos = AT( ".", lcNumber)
IF lnPos = 0
lnResult = 0
ELSE
lnResult = LEN( lcNumber) - lnPos
ENDIF

RETURN lnResult


Bye
Jayesh
- Jayesh
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform