Anjala Baby
asked on
Rounding off Issue using Math.Round()
Hi Experts,
I have tried to round off a value x = 455.77 using math .round() function but not rounded the value 466.
Code I have given to round off:
Could you guys please explain whats wrong here?
Thanks,
Anjala Baby
I have tried to round off a value x = 455.77 using math .round() function but not rounded the value 466.
Code I have given to round off:
var rounded = Math.Round(x, 2, MidpointRounding.AwayFromZero);
Could you guys please explain whats wrong here?
Thanks,
Anjala Baby
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So, How the value 455.50 will be rounded if we use '0' in round function?
Do you want 456.00 for this?
ASKER
No, I just want to know how the result will be when we give value as 455.5. Will it be 455 or 456?
It will give you 456.0
If you use this ROUND(455.45,0) then you will get 455.00
ASKER
Thank you guys for the answers.
var rounded = Math.Round(x, 0, MidpointRounding.AwayFromZ