I notice that if I do the following:

Math.Round(ctype(4.935, Decimal), 2, MidpointRounding.AwayFromZero)

I get the desired result. Is there any problem converting a double to

a decimal like this?

rowe_newsgroups wrote:

Is this a bug?

As far as I'm concerned, yes. Check out this similar thread to see an

explaination:

http://groups.google.com/group/micro...748c717a6c3a36

Thanks,

Seth Rowe

Altman wrote:
OK I was having rounding problems before and I didn't realize that

their was a third parameter in the round function that would tell it if

it a 5 to round up. I thought adding this would fix the problem but it

didn't. I have VS 2005 and I am using vb.net try rounding the number

4.935 to 2 decimals:

What I am seeing is the following:

Math.Round(4.935, 2, MidpointRounding.AwayFromZero) 'Result is 4.93

Math.Round(4.935, 2, MidpointRounding.ToEven) 'Result is

4.93

Is this a bug? Am I just missing something?

I want 5 to round up which means AwayFromZero should do it right? In

this case even if I did ToEven it should go to 4.94 but it isn't. Is

it best to just abandon the round function in .Net and make my own. I

feel that rounding is such a basic function that I shouldn't have to

make my own function. Is this a floating point problem with .Net?

Right now I don't know if I can trust the round function that is built

in.