public static function humanSize($size, $max = null, $system = 'si', $retstring = '%01.2f %s')
    {
        // Pick units
        $systems = array();
        $systems['si']['suffix'] = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
        $systems['si']['size']   = 1000;
        $systems['bi']['suffix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
        $systems['bi']['size']   = 1024;
        $sys = isset($systems[$system]) ? $systems[$system] : $systems['si'];

        // Max unit to display
        $depth = count($sys['suffix']) - 1;
        if ($max && false !== $d = array_search($max, $sys['suffix'])) {
            $depth = $d;
        }

        // Loop
        $i = 0;
        while ($size >= $sys['size'] && $i < $depth) {
            $size /= $sys['size'];
            $i++;
        }

        return sprintf($retstring, $size, $sys['suffix'][$i]);
    }