### Rounding up to the .5

Looking to write a program that rounds up to the .5, not by .5 or to the whole number.

eg- 3.4 = 3.5 not 3.4 = 3.9 or 3.4 = 4.0

Basically, want to write a labor calculation that charges by the half hour for increments thereof.

Have been monkeying around a while with a manual rounding function which I enter outside int main. Have had really strange results. Have only so far been able to achieve simple ceil rounding up to the whole number with the built-in

value = ceil (value);

Any other ideas would be more than welcome. I have been trying many of the other forum entries I have seen that are somewhat related to the subject, but noone I have seen who wanted to do precisely this task.
Try this:

 `` `` ``value = ceil( value * 2) / 2;``

It isn't a very efficient solution, but it should work nicely (It would be more efficient to directly set / get the appropriate mantisse bits of value)
Maybe this would do it.
`N<(floor(N)+ceil(N))/2 ? (floor(N)+ceil(N))/2) : N;`
Topic archived. No new replies allowed.