private static function formatFloat($f, $precision)
    {
        $scale = pow(10, max(0, $precision));
        // clear off additional digits so that number_format doesn't round numbers
        $i = (int)($f * $scale) / $scale;
        return number_format($i, $precision, '.', '');
    }