Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decimal precision is of a variable
Message
De
19/09/1998 10:09:27
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00136301
Message ID:
00138632
Vues:
18
>Hi,
>
>What i did was save the variable using sql to a dbf and use afield.
>
>Crude but it worked.
>
>
>
>>>Is there a command that returns the decimal precision of a variable?
>>>

You're using SQL's field mapping, actually; it's really using the minimal number of decimals it needs. Would you, please, try something like this:

x=3.005
x=x+x
Now measure the number of decimals for x with your method. You should get two decimal places, though x could have been three-decimaled for hours before this. If the number of decimals until the last non-zero digit is the issue, you may try this:

Func DecimalLen
Lpara x
Local DecString
decstring=str(x-int(x), 18,16)+space(1) && make it a number in a form of 0.xxxxxxxxxxxxx and add a space
do while "0 "$ decstring
decstring=strtran(decstring, "0 "," ") && replace any zero+space with just space, thus dropping one rightmost zero each time
endd
Return len(decstring-3) && take three for initial 0. and the trailing space

No cursors, no buffers, just a little UDF.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform