private function encodeFloat($float, $precision)
    {
        $log = (int) floor(log(abs($float), 10));

        if ($log > -5 && abs($float) < self::FLOAT_MAX && abs($log) < $precision) {
            return $this->formatFloat($float, $precision - $log - 1);
        }

        // Deal with overflow that results from rounding
        $log += (int) (round(abs($float) / 10 ** $log, $precision - 1) / 10);
        $string = $this->formatFloat($float / 10 ** $log, $precision - 1);

        return sprintf('%sE%+d', $string, $log);
    }