public function format($bytes, $precision = null)
    {
        // Use default precision when not specified.
        $precision === null && $precision = $this->getPrecision();

        $log = log($bytes, $this->getBase());
        $exponent = $this->hasFixedExponent() ? $this->getFixedExponent() : max(0, $log|0);
        $value = round(pow($this->getBase(), $log - $exponent), $precision);
        $units = $this->getUnitDecorator()->decorate($exponent, $this->getBase(), $value);

        return trim(sprintf($this->sprintfFormat, $this->formatValue($value, $precision), $units));
    }