1

I am aware of what the ceil function does, it rounds numbers up. So; 1.3 to 2.0 and 5.9 to 6.0. But I want it to round up with steps of 0.5. So; 1.3 to 1.5 and 5.9 to 6.0. Is this possible? Thanks!!!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Vince
  • 648
  • 1
  • 7
  • 17

1 Answers1

4
y = ceil(x * 2.0)/2.0;

should do what you need:

x     x*2.0   ceil(x*2.0)  y
------------------------------
1.3    2.6     3.0         1.5
1.6    3.2     4.0         2.0
5.9   11.8    12.0         6.0
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382