Decimal.Round() function return result false

  • Thread starter Thread starter Hoang Duc Chau
  • Start date Start date
H

Hoang Duc Chau

Hi Guy,
Dim dTestA As Decimal = Decimal.Round(6.75, 1)
dTestA return 6.8 (right)
Dim dTestB As Decimal = Decimal.Round(6.65, 1)
dTestB return 6.6 (false) while i expected the result is 6.7
Any idea on how to solve this?

Thanks
Hoang Duc Chau
 
Hoang said:
Hi Guy,
Dim dTestA As Decimal = Decimal.Round(6.75, 1)
dTestA return 6.8 (right)
Dim dTestB As Decimal = Decimal.Round(6.65, 1)
dTestB return 6.6 (false) while i expected the result is 6.7
Any idea on how to solve this?

Thanks
Hoang Duc Chau

By default, it uses "Bankers Rounding". There are ways to change this
behaviour, and we had a discussion either in here or in
microsoft.public.dotnet.framework recently, so google on that.

Damien
 

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

Back
Top