Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Truncating a numeric value
Message
 
À
26/10/1999 23:47:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00282036
Message ID:
00282060
Vues:
27
>>Is there any pre-defined function in VFP that allows the truncation of a decimal. For example if I want to get 0.465 from 0.4655? Any form of help is appreciated.
>>
>>Thanks.
>
>Hmm. Not a native function that I know of, butyou could use this:
>
>x = 0.4655
>n = 3 && number of decimals to round to
>lnRounded = INT(x*10^n)/10^n
>
>Even works for rounding to places to the left of he decimal by using a negative number for n.

How about something like:

ln = 0.4655
lc =STR(ln, 9,4)
lc = SUBSTR(lc,1,len(lc) -1)
set decimals to 3
ln = VAL(lc)
**** 0.465

:)
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform