Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Round up problem
Message
From
16/08/2007 12:14:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
01/08/2007 11:02:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01245162
Message ID:
01248547
Views:
20
>round(myfield,2)
>if myfield = 2.159 . the return result is 2.16 (which is correct)
>However, if myfield =-2.159 , the return result becomes -2.1
>my client complaint the result should be -2.16 , but not -2.1
>
>any round up function for -ve ?

If the field has a sufficient length, then it will store the decimal part correctly; if you try to store -2.159 into a n(4,2) field, you'll get -2.2 (which takes four characters to write, and four you have), don't know how you got -2.1, though. Just widen the field, because the minus sign also takes one character. In a n(5,2) field, it stores correctly, as -2.16.

You could use something like this if you want, though it's unnecessary - your problem is in the width of the field:
lPARAMETERS nnum, ndec
RETURN ROUND(ABS(nnum), ndec)*SIGN(nnum)

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform