How to round up to closest .5 using C#

msk*_*msk 1 c# math function

Working with a time clocking system a lot of the hours clocked end up looking like this:

0.266666666666.

Now, I want to round up all the numbers to the "next .5 value", such that 0.2666666666 becomes 0.5.

Examples:

1.4 => Should become 1.5
1.45 => Should become 1.5
1.466666666 => Should become 1.5
1.0 => Should remain 1.0
1.6 => Should become 2.0
Run Code Online (Sandbox Code Playgroud)

The numbers need to always be rounded up.

I would be very grateful for any help on how to achieve this in C#!

kei*_*ith 5

I think you want something like this:

Math.Ceiling(value / 0.5) * 0.5
Run Code Online (Sandbox Code Playgroud)