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:
00759712
Vues:
20
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 )
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform