I want to round up always in c#, so for example, from 6.88 to 7, from 1.02 to 2, etc.
How can I do that?
Integer division truncates in C, yes. (i.e. it's round towards zero, not round down.) round toward 0 meaning . 5 or greater => round up 0 to .
In the C Programming Language, the floor function returns the largest integer that is smaller than or equal to x (ie: rounds downs the nearest integer).
C ceil() The ceil() function computes the nearest integer greater than the argument passed.
Use Math.Ceiling()
double result = Math.Ceiling(1.02);
Use Math.Ceiling: Math.Ceiling(value)
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