## 3 replies

Last post Jan 14, 2011 05:04 AM by shabirhakim1

None

0 Points

2 Posts

### Round function problem

Jan 14, 2011 03:11 AM|Aaqib Inam|LINK

Dear(s),

In vb.net i am going to round a number but it is not Giving me correct answer. i.e.

Round (1.5,0) = 2

Round (2.5,0) = 2   which is wrong. the answer should be 3.

(When i use the Round formula in Excel it gives me the correct answer)

Aaqib Inam

Aaqib Inam

Star

10830 Points

2415 Posts

### Re: Round function problem

Hi Aqib

<div><div class="summary">

Rounds a double-precision floating-point value to the nearest integral value.

If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned

</div></div>

<div class="LW_CollapsibleArea_Container"><div class="LW_CodeSnippetContainer"><div class="LW_CodeSnippetContainerCodeCollection"><div id="CodeSnippetContainerCode0" class="LW_CodeSnippetContainerCode"> <div style="color: Black;" mce_style="color: Black;">
`'DeclarationPublic Shared Function Round ( _	a As Double _) As Double`
</div> </div> </div> </div> <div id="parameters">

#### Parameters

a
Type: System.Double
A double-precision floating-point number to be rounded.
</div> <div id="returns">

#### Return Value

Type: System.Double
The integer nearest a. If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns a Double instead of an integral type.</div></div>

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding. It minimizes rounding errors that result from consistently rounding a midpoint value in a single direction.

To control the type of rounding used by the Round method, call the Math.Round(Double, MidpointRounding) overload.

Go here For Example http://msdn.microsoft.com/en-us/library/wyk4d9cy.aspx

Regards

shabir

Please if the post helped you.

None

0 Points

2 Posts

### Re: Round function problem

Jan 14, 2011 04:58 AM|Aaqib Inam|LINK

Dear Shabir, I got the problem. But one thing more which i want to know from you. I am also using the classic asp 3.0 and this function is also giving the problem. is there any solution for classic asp ?

Regards,

Aaqib Inam

Aaqib Inam

Star

10830 Points

2415 Posts