Round function

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

Hi

Dont know exactly how to explain.

I have a field name cost, currency 4 digits afler dot.
The second field is setup to Round cost 2 digits after dot.

The problem is
If my cost is like : 1.0050 when I round (cost;2)
it give me the result of 1.00
It did not recongnise the 5 and then not give me
1.01
I tought to add in my procedure
a variable call priceok

If right (2)[cost] = 5 then of *(4 digits)
right (1)[priceok] = 1 of *(2digits)
else
price = round(cost;2)
endif

I am trying to find a solution. May bee you can help.

I hope

Thanks in advance

Claire
 
Claire,

The Round() function moves an exact 5 in the trailing place to the
nearest even number. So...
Round(1.115;2) = 1.12
Round(1.125;2) = 1.12
Round(1.135;2) = 1.14
Round(1.005;2) = 1.00
.... etc.

This is correct, and by design. It helps to balance out inaccuracies
that would arise with totals or averages of large numbers of items if
the rounding always happened in one direction.

So, if for some reason you want your database to behave differently, you
will, as you suggested, need to use something other than the simple
Round() function. I think this will work...
Price = Round(([Cost]*100+0.005)/100,2)
 
Back
Top