One way to do that would be this:
return floor(value*4.0)*0.25;
This translates a value of 0.25 into 0.25. If you need to translate it into 0.0, use this:
return ceil(value*4.0)*0.25-0.25;
But be aware that this will also translate 0.0 into -0.25. If that's not acceptable, you could use this:
return value < 0.25 ? 0 : ceil(value*4.0)*0.25-0.25;
Or another alternative:
return ceil(value*4.0)*0.25 - (fmod(value,1) ? 0.25 : 0);
Here's a short test program:
#include <iostream>
#include <cmath>
float round(float value)
{
return ceil(value*4.0)*0.25 - 0.25;
}
int main()
{
for (float i=0.0; i < 1.5; i+=0.05)
std::cout << i << " ==> " << round(i) << '\n';
}