Round()

Q

Question Boy

I am seriously confused and need someone to explain the Round() function.

I have a form which has a control that uses the following Control Source

=([Sous-total]+[Sous-total Mechanique])*0.07

Which returns a value of 8.085 (in one case)

I then mod the Control Source like

=Round(([Sous-total]+[Sous-total Mechanique])*0.07,2)

and it now returns 8.08?????

What am I doing wrong? Why is it not returning 8.09? How can I make it?!

Thank you.

Confused and Frustrated!
QB
 
T

Tom van Stiphout

On Thu, 12 Feb 2009 05:54:53 -0800, Question Boy

Type this in the Immediate window:
?Round(8.085,2)
8.09

Conclusion: what is DISPLAYED as 0.085 is actually a fraction less
than that, and that number would round down.

-Tom.
Microsoft Access MVP
 
R

RonaldoOneNil

But, if you type ? Round((100+15.5)*0.07,2) you get 8.09
If you set the control source proprerty of a text box on a form to
=(100+15.5)*0.07
it displays as 8.085. On a calculator it shows 8.085
If you then put this code behind a button click
Msgbox Round(textboxname,2)
8.08 is displayed ??

Tom van Stiphout said:
On Thu, 12 Feb 2009 05:54:53 -0800, Question Boy

Type this in the Immediate window:
?Round(8.085,2)
8.09

Conclusion: what is DISPLAYED as 0.085 is actually a fraction less
than that, and that number would round down.

-Tom.
Microsoft Access MVP


I am seriously confused and need someone to explain the Round() function.

I have a form which has a control that uses the following Control Source

=([Sous-total]+[Sous-total Mechanique])*0.07

Which returns a value of 8.085 (in one case)

I then mod the Control Source like

=Round(([Sous-total]+[Sous-total Mechanique])*0.07,2)

and it now returns 8.08?????

What am I doing wrong? Why is it not returning 8.09? How can I make it?!

Thank you.

Confused and Frustrated!
QB
 
A

Allen Browne

The Round() function in Access uses bankers rounding.

Details:
http://allenbrowne.com/round.html#BankersRounding

As Tom points out, there is also a matter of tiny inaccuracies in floating
point values that can give an answer different to what you expect:
http://allenbrowne.com/round.html#FloatingPointErrors

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

RonaldoOneNil said:
But, if you type ? Round((100+15.5)*0.07,2) you get 8.09
If you set the control source proprerty of a text box on a form to
=(100+15.5)*0.07
it displays as 8.085. On a calculator it shows 8.085
If you then put this code behind a button click
Msgbox Round(textboxname,2)
8.08 is displayed ??

Tom van Stiphout said:
On Thu, 12 Feb 2009 05:54:53 -0800, Question Boy

Type this in the Immediate window:
?Round(8.085,2)
8.09

Conclusion: what is DISPLAYED as 0.085 is actually a fraction less
than that, and that number would round down.

-Tom.
Microsoft Access MVP


I am seriously confused and need someone to explain the Round()
function.

I have a form which has a control that uses the following Control Source

=([Sous-total]+[Sous-total Mechanique])*0.07

Which returns a value of 8.085 (in one case)

I then mod the Control Source like

=Round(([Sous-total]+[Sous-total Mechanique])*0.07,2)

and it now returns 8.08?????

What am I doing wrong? Why is it not returning 8.09? How can I make
it?!

Thank you.

Confused and Frustrated!
QB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top