Decimal Round Up Question

  • Thread starter Thread starter Tsair
  • Start date Start date
T

Tsair

I found the decimal round up problem,

System.Math.Round(106.865, 2)= 106.86
System.Math.Round(106.875, 2) = 106.88
System.Math.Round(106.885, 2) = 106.88
System.Math.Round(106.895, 2) = 106.9

Why some time it round up the 5 and sometime roun down the 5 ?
 
Tsair,

Because DotNet uses the ISO Banking rounding method. On my question in these
newsgroups who was using that beside Banks (between each other not to
customers) I never got any anser.

In past there where a lot of articles about that on MSDN but I cannot find
them anymore. It is about the even and odd situation of a value that tells
it it is rounded up or down.

Cor
 
Tsair said:
I found the decimal round up problem,

System.Math.Round(106.865, 2)= 106.86
System.Math.Round(106.875, 2) = 106.88
System.Math.Round(106.885, 2) = 106.88
System.Math.Round(106.895, 2) = 106.9

Why some time it round up the 5 and sometime roun down the 5 ?

Firstly, just to be clear, this is talking about rounding the Double
type, not the Decimal type.

Secondly, this behaviour is as described in the documentation for
Math.Round:

<quote>
Return Value
The number nearest value with a precision equal to digits. If value is
halfway between two numbers, one of which is even and the other odd,
then the even number is returned. If the precision of value is less
than digits, then value is returned unchanged.
</quote>
 

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

Similar Threads

Math.Round() 13
Rounding Issue 4
I want to correct Round function 17
Round up 10th of Decimal 1
Custom decimal round 14
Round a number/ Access 2007 4
Excel Excel 2007 won't stop rounding down my formula results! 5
Rounding problem 9

Back
Top