Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Truncating a numeric value
Message
 
To
26/10/1999 23:47:37
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00282036
Message ID:
00282060
Views:
28
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform