I want to round 54.5345 to 54.54 that is if I have a third decimal place then i want to add 1 to the 2nd decimal place.
I have tried using math.round but it always rounds down if the third decimal is less than 5
try:
d = Math.Ceiling(d * 100) / 100;
where d is your decimal.
I think you should try this:
double a = Math.Round(-57.5345, 2);
This works for negative numbers too.
The way you are rounding off is not correct.
You can also refer:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.