Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round() Bug
Message
De
04/01/2001 16:21:17
Mike Mattos
Nationwide Computers
Mississauga, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00459503
Message ID:
00459563
Vues:
23
FoxPlus Unix had problems rounding negative numbers ( -.5 rounds to 0, not -1 )

THAT make reversing accounting entries lots of fun when the sales tax was 7% !

SO I re-wrote the round function, learned that it helped to multiply the number first by the # of decimals, so I rounded BIG positive numbers all the time, and them reduced them again.

parameter num2round, numdecs
tc_factor = "1" + replicate("0",numdecs)
tl_neg= .f
num2round=num2round * val(tc_factor)
IF num2round < 0
num2round = num2round * (-1)
tl_neg=.t.
ENDIF
num2round=num2round + 5
num2round=num2round / val(tc_factor)
if tl_neg
num2round=num2round*-1
ENDIF

return num2round

Big problem was that it was easier to put the numbers in logical order, but the pennies never seemed to work out right!

I believe part of the ROUND() problem is that rigourous math has different rules than accounting arithmetic, can't please all the people all the time!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform