Quantcast
Channel: Round DOWN to nearest half integer in PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Round DOWN to nearest half integer in PHP

$
0
0

I need a PHP function that will take a float and round it down to the nearest half (x.0 or x.5). I found other functions that will round to the nearest fraction, but they round both ways.

The function I need can only round down.

Examples

7.778 -> 7.5

7.501 -> 7.5

7.49 -> 7.0

7.1 -> 7.0


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>