Group:  Microsoft Access ยป microsoft.public.access.forms
Thread: Round function

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Round function
"Claire" <claimarc[ at ]mediom.qc.ca> 30.09.2006 01:27:56
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














Re: Round function
Steve Schapel <schapel[ at ]mvps.org.ns> 30.09.2006 03:11:49
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)

--
Steve Schapel, Microsoft Access MVP

Claire wrote:
[Quoted Text]
> 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

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net