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:
00759712
Views:
23
Here's a quick routine to determine decimals WITH a value: ie: 1.234 goes out to 3 decimals, but doesn't account 2.000 for 3 decimal positions. Maybe this will work for your needs with some mods...
x = 1
? decpos( x )
x = 1.1
? decpos( x )
x = 1.12
? decpos( x )
x = 1.123
? decpos( x )
x = 1.1234
? decpos( x )
x = 1.12345
? decpos( x )
x = 1.123456
? decpos( x )


func decpos
lparameters lnX

lnI = 0
llMatch = .F.
do while NOT llMatch
	if ( lnX * ( 10 ^ lnI )) - int( lnX * (10 ^ lnI )) = 0
		llMatch = .T.
	else
		lnI = lnI + 1
	endif
enddo
return( lnI )
Previous
Reply
Map
View

Click here to load this message in the networking platform