Round to 0.5, 1.5, 2.5 ...

Is there a way to round a number in increments of one but to be offset by one? So for example if a number is 0.7 it would round down to 0.5 and if a number is 1.2 it will round up 1.5. Would it use Mathf.Round or is this impossible? Thanks


float roundedValue = ((int)input) + 0.5f;

That should do it.

If you want to use negative numbers, then use this instead:

float output = Mathf.Sign(input) * (Mathf.Abs((int)input) + 0.5f);