Information générale
Catégorie:
Codage, syntaxe et commandes
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement