Rounding to values ending in 0.5 rather than 0.0

Silly math question here… I’m having trouble finding a way to round values to end in .5 rather than 0’s. For example what I want is…

0.9 = 0.5
1.0 = 1.5
1.2 = 1.5
1.9 = 1.5
2.1 = 2.5

and so on.

Right now I’m able to get numbers to round to 0.0, 0.5, 1.0, 1.5… But I’m having trouble figuring out how to get it to omit the 1.0 2.0 values and only give me the .5’s.

show us the code you are currently using…

var roundedFoo = Mathf.Round (foo - .499999) + .5;

–Eric

Surely:

var roundedFoo = Mathf.Floor(foo) + .5;

+1 for this. Using Floor gives you the whole number, then just add the .5 back to it.