Round() Function not returning exepcted results

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

OS:WinXP
Access 2k3 (2k file format)

Im trying to round currency using the Round() function for example:

If Rst_Inventory_Master![Taxable-Burlington] = True Then
ExtendedSale = Rst_Inventory_Master![Price] * Me.txt_Amount.Value
TaxCollectedRAW = (ExtendedSale * LocationTaxRate)
TaxCollected = Round(TaxCollectedRAW, 2)
Rst_SalesTemp![Tax] = TaxCollected
Else
Rst_SalesTemp![Tax] = 0
End If

TaxCollectedRAW = .765
TaxCollected = Round(TaxCollectedRAW, 2)

I would expect the Round function to return a value of .77 but it is
returning a value of .76

All variables are declared as Currency types.

If there is something i am overlooking here please pass your knowledge along

Thanks
-
Joseph Schroeder
Director of Software Development
Vazcom Communications Inc.
 
The Round function uses what's referred to as Banker's Rounding. Banker's
Rounding rounds .5 up sometimes and down sometimes. The convention is to
round to the nearest even number, so that both 1.5 and 2.5 round to 2, and
3.5 and 4.5 both round to 4. Banker's rounding is symmetric. The rationale
is that when you add rounded values together, always rounding .5 in the same
direction results in a bias that grows with the more numbers you add
together.

See http://support.microsoft.com/?kbid=196652 for a detailed discussion on
rounding.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Joseph Schroeder - Vazcom"
 
Thanks Douglas

I will read and try to implement.

It's just annoying when all i want to do is round up to the nearest penny if
im sitting at a half cent.

I'm writing a custom POS system and the taxes need to be precise.

Thanks again
--
Joseph Schroeder
Director of Software Development
Vazcom Communications Inc.


Douglas J Steele said:
The Round function uses what's referred to as Banker's Rounding. Banker's
Rounding rounds .5 up sometimes and down sometimes. The convention is to
round to the nearest even number, so that both 1.5 and 2.5 round to 2, and
3.5 and 4.5 both round to 4. Banker's rounding is symmetric. The rationale
is that when you add rounded values together, always rounding .5 in the same
direction results in a bias that grows with the more numbers you add
together.

See http://support.microsoft.com/?kbid=196652 for a detailed discussion on
rounding.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Joseph Schroeder - Vazcom"
OS:WinXP
Access 2k3 (2k file format)

Im trying to round currency using the Round() function for example:

If Rst_Inventory_Master![Taxable-Burlington] = True Then
ExtendedSale = Rst_Inventory_Master![Price] * Me.txt_Amount.Value
TaxCollectedRAW = (ExtendedSale * LocationTaxRate)
TaxCollected = Round(TaxCollectedRAW, 2)
Rst_SalesTemp![Tax] = TaxCollected
Else
Rst_SalesTemp![Tax] = 0
End If

TaxCollectedRAW = .765
TaxCollected = Round(TaxCollectedRAW, 2)

I would expect the Round function to return a value of .77 but it is
returning a value of .76

All variables are declared as Currency types.

If there is something i am overlooking here please pass your knowledge along

Thanks
-
Joseph Schroeder
Director of Software Development
Vazcom Communications Inc.
 
"Joseph Schroeder - Vazcom"
I'm writing a custom POS system and the taxes need to be precise.

Been there, and doing that.... I settled for writing a custom function that
does the rounding I want based on my own desires. That way, I "know" what
the result will be and I don't have to rely on Round function.
 
=?Utf-8?B?Sm9zZXBoIFNjaHJvZWRlciAtIFZhemNvbQ==?=
It's just annoying when all i want to do is round up to the nearest
penny if im sitting at a half cent.

= iif(int(amount)=amount, amount, int(amount+1))

Hope that helps


Tim F
 
Back
Top