Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round up problem
Message
De
16/08/2007 12:14:33
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
01/08/2007 11:02:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01245162
Message ID:
01248547
Vues:
22
>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform