I want to round up double value in two decimal places in c# how can i do that?
double inputValue = 48.485;
after round up
inputValue = 48.49;
2f" tells the printf method to print a floating point value (the double, x, in this case) with 2 decimal places.
Using the ceil() function to round to 2 decimal places in C++ The ceil() function returns the smallest integer greater than the given integer. It will round up to the nearest integer. We can use this function to round to 2 decimal places in C++.
This works:
inputValue = Math.Round(inputValue, 2);
Math.Round(inputValue, 2, MidpointRounding.AwayFromZero)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With