Formats a float to not display in scientific notation.

@param float $float
the float to format

@return double|string
the formated float
960299
public function formatFloat($float)
    {

        if (!$float) {
            return $float;
        }

        $zeroFraction = $float - floor($float) == 0 ? '0' : '';

        // We don't want values like 0.004 converted to 0.00400000000000000008
        if ($float > 0.0001) {
            return $float.($zeroFraction === '0' ? '.'.$zeroFraction : '');
        }

        // We don't want values like 0.00004 converted to its scientific notation 4.0E-5
        return rtrim(sprintf('%.20F', $float), '0').$zeroFraction;
    }
565882
public static function trim($n)
    {
        $float         = floatval($n);
        $decimalPlaces = 0;

        // If the number rounded to $decimalPlaces isn't equal to the float val, add another decimal place and try again
        while ($float != round($float, $decimalPlaces)) {
            $decimalPlaces++;
        }

        $decimalPlaces = ($decimalPlaces < 2) ? 2 : $decimalPlaces;

        return number_format($float, $decimalPlaces, ".", "");
    }
917048
public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
    {
        return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
    }
336493
public static function typeof($data) {
        if ($data instanceof \Closure) return "closure";

        $type = strtolower(gettype($data));
        if ($type === "double") return "float";
        return $type;
    }
377500
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);
    }
1213908
public static function formatCurrency(float $value, string $currency, int $format = null) : string
    {
        $formatter = new NumberFormatter(self::translator()->getIETF(), NumberFormatter::CURRENCY);

        if ($format && $format & self::FORMAT_SHORT) {
            $diff = pow(10, -$formatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
            $decimal = (float) (floatval((string) $value) - (int) floatval((string) $value));

            if ($decimal < $diff) {
                $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 0);
            }
        }

        return $formatter->formatCurrency($value, $currency);
    }
1119042
def _latex_float(f, format=".3g"):
    
    float_str = "{{0:{0}}}".format(format).format(f)
    if "e" in float_str:
        base, exponent = float_str.split("e")
        return r"{0}\times 10^{{{1}}}".format(base, int(exponent))
    else:
        return float_str
819302
public static function format($value)
    {
        $value = (string) $value;

        if (Utils::isAddress($value)) {
            $value = mb_strtolower($value);

            if (Utils::isZeroPrefixed($value)) {
                return $value;
            }
            return '0x' . $value;
        }
        $value = IntegerFormatter::format($value, 40);

        return '0x' . $value;
    }
142428
def format_float(x, max_width):
    '''
    '''
    # width of (whole part + 1 (to avoid zero)) + 1 because int floors, not ceils
    whole_width = int(math.log10(abs(x) + 1)) + 1
    # for +/- sign
    sign_width = 1 if x < 0 else 0
    # for . if we show it
    decimal_point_width = 1 if max_width >= whole_width else 0
    return '%.*f' % (max_width - whole_width - sign_width - decimal_point_width, x)
1005610
public static function formatMethod($frame)
    {
        if (!empty($frame['class']) && !empty($frame['type']) && !empty($frame['function'])) {
            return sprintf('%s%s%s()', $frame['class'], $frame['type'], $frame['function']);
        } else {
            return sprintf('%s()', !empty($frame['function']) ? $frame['function'] : '<unknown>');
        }
    }
279641
public function getString($value)
    {
        $number = floatval($value);
        $number = round(($number + 0.000001) * 20) / 20;

        return sprintf('CHF %s',
            number_format($number, 2, '.', '\'')
        );
    }
1172681
public function format(float $time, string $unit = null, string $mode = null, int $precision = null, bool $suffix = true)
    {
        $value = number_format($this->toDestUnit($time, $unit, $mode), $precision !== null ? $precision : $this->precision);

        if (false === $suffix) {
            return $value;
        }

        $suffix = $this->getDestSuffix($unit, $mode);

        return $value . $suffix;
    }
732427
public static function abs($float)
    {
        if (!static::is($float)) {
            throw new \InvalidArgumentException(
                "The \$float parameter must be of type float (or string representing a big float)."
            );
        }

        if (Float::is($float)) {
            return Float::abs($float);
        } else {
            return Str::replace($float, '-', '');
        }
    }
4510
public function format_float($field)
    {
        $precision = 2;
        $m = (float) $this->current_row[$field];
        $this->current_row[$field] =
            is_null($this->current_row[$field])
                ? '-'
                : number_format($m, $precision);
        $this->setTDParam($field, 'align', 'right');
        $this->setTDParam($field, 'style/white-space', 'nowrap');
    }
491045
public function getValue() {
        $value = parent::getValue();
        if ($value) {
            $value = unformat_float($value, true);
        }
        return $value;
    }
1328798
public static function mul($float1, $float2)
    {
        if (!static::is($float1) || !static::is($float2)) {
            throw new \InvalidArgumentException("The \$float1 and \$float2 parameters must be of type float.");
        }

        return ($float1 * $float2);
    }
1359718
public function convert($value)
    {
        if (!is_scalar($value)) {
            return false;
        }

        if (is_string($value)) {
            return $value;
        }

        if (is_float($value)) {
            return sprintf('float_%.4f', $value);
        }

        $prefix = '';

        if (!is_bool($value)) {
            $prefix = gettype($value) . '_';
        }

        
        return $prefix . var_export($value, true);
    }