underscore-php icon indicating copy to clipboard operation
underscore-php copied to clipboard

add Float type, with stuff that twig_round does

Open laland opened this issue 10 years ago • 0 comments

function twig_round($value, $precision = 0, $method = 'common')
{
    if ('common' == $method) {
        return round($value, $precision);
    }

    if ('ceil' != $method && 'floor' != $method) {
        throw new Twig_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.');
    }

    return $method($value * pow(10, $precision)) / pow(10, $precision);
} 

Why not to add this: Float::ceil($float, $precision) Float::floor($float, $precision)

laland avatar Dec 22 '15 23:12 laland