[removed] rounding a float UP to nearest .25 (or whatever…)

后端 未结 4 1544
广开言路
广开言路 2021-01-21 03:39

All answers I can find are rounding to nearest, not up to the value... for example

1.0005 => 1.25  (not 1.00)
1.9   => 2.00
2.10 => 2.25
2.59 => 2.75         


        
4条回答
  •  有刺的猬
    2021-01-21 04:15

    Multiply the number by 4, use Math.ceil on the result and then divide that number by 4.

提交回复
热议问题