Last post Jan 14, 2011 05:04 AM by shabirhakim1
Jan 14, 2011 03:11 AM|Aaqib Inam|LINK
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
(When i use the Round formula in Excel it gives me the correct answer)
Please help me to solve this prblem.
Jan 14, 2011 03:35 AM|shabirhakim1|LINK
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
'DeclarationPublic Shared Function Round ( _ a As Double _) As Double
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
To control the type of rounding used by the Round method, call the
Math.Round(Double, MidpointRounding) overload.
Go here For Example
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 ?
Jan 14, 2011 05:04 AM|shabirhakim1|LINK
If you want better control, then look into the floor and ciel functions. floor always rounds down and ciel always rounds up.
This page has some good info about rounding across all vb-esque languages: