Decimal.Round() function return result false

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
 
D

Damien

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
 
Joined
Dec 26, 2010
Messages
1
Reaction score
0
This issue is there in C# also. Resolution

This issue is there in C# also.

I used following solution to resolve. May this help somebody.

decimal dVaue = 1777.325M;
decimal dRounded = Decimal.Parse(dVaue.ToString("0.00"));

-- Noushad
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top