Use Math.Ceiling
to round up
Math.Ceiling(0.5); // 1
Use Math.Round
to just round
Math.Round(0.5, MidpointRounding.AwayFromZero); // 1
And Math.Floor
to round down
Math.Floor(0.5); // 0
More Related Contents:
- Math.Round doesn’t behave like i want it to. (X.0xxxxx numbers) [closed]
- Truncate Two decimal places without rounding
- Round a double to x significant figures
- Built in .Net algorithm to round value to the nearest 10 interval
- C# Line is horizontal
- How to check if a number is a power of 2
- How do you round a number to two decimal places in C#?
- All Possible Combinations of a list of Values
- Rounding integer division (instead of truncating)
- How do I round to the nearest 0.5?
- How to calculate float type precision and does it make sense?
- Smoothly connecting circle centers
- How do I determine the standard deviation (stddev) of a set of values?
- Algorithm to find which numbers from a list of size n sum to another number
- How deterministic is floating point inaccuracy?
- Double precision problems on .NET
- 3D relative angle sum calculation
- Best way to find all factors of a given number
- How to tell whether a point is to the right or left side of a line
- How can I get a count of the total number of digits in a number?
- Rounding integers to nearest multiple of 10 [duplicate]
- Calculate a point along the line A-B at a given distance from A
- How to force a number to be in a range in C#? [duplicate]
- How can I generate truly (not pseudo) random numbers with C#?
- How can I calculate divide and modulo for integers in C#?
- Round a decimal to the nearest quarter in C#
- Fastest implementation of log2(int) and log2(float)
- Best algorithm for evaluating a mathematical expression?
- how to calculate reverse modulus
- Why doesn’t C# use arithmetic overflow checking by default? [duplicate]