Multiply your rating by 2, then round using Math.Round(rating, MidpointRounding.AwayFromZero)
, then divide that value by 2.
Math.Round(value * 2, MidpointRounding.AwayFromZero) / 2
More Related Contents:
- I need help in meeting a certain criteria for a function in C#
- Math.Round doesn’t behave like i want it to. (X.0xxxxx numbers) [closed]
- Evaluating string “3*(4+2)” yield int 18 [duplicate]
- Random.Next returns always the same values [duplicate]
- How to tell whether a point is to the right or left side of a line
- All Possible Combinations of a list of Values
- Arithmetic operator overloading for a generic class in C#
- Mod of negative number is melting my brain
- How to calculate float type precision and does it make sense?
- Round a double to x significant figures
- Should functions return null or an empty object?
- Smoothly connecting circle centers
- 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?
- Rotate a point by another point in 2D
- Calculating point on a circle’s circumference from angle in C#?
- Calculate a point along the line A-B at a given distance from A
- How do you do *integer* exponentiation in C#?
- Performing Math operations on decimal datatype in C#?
- What’s the quickest way to compute log2 of an integer in C#?
- Arbitrary precision decimals in C#?
- Get the calling function name from the called function [duplicate]
- Fastest implementation of log2(int) and log2(float)
- The algorithm to find the point of intersection of two 3D line segment
- How sqrt() of GCC works after compiled? Which method of root is used? Newton-Raphson?