Display a nice area.

@param string|int|float $number
@param int              $decimals (optional)

@return string
974512
public function area($number, $decimals = 0, $unit = null)
    {
        if (!is_numeric($number) || !$number) {
            return '';
        }

        if (!$this->localizer) {
            return $this->number($number, $decimals).' '.($unit ?: 'sqin');
        }

        if (!$unit) {
            $unit = $this->localizer->measuring() == 'imperial' ? 'sqin' : 'm²';
        }

        return $this->localizer->length($number, $decimals, $unit);
    }
990761
public function format($number, $options = [])
    {
        return $this->formatter()->format($number,
            $this->mergeOptions($options)
        );
    }
1231308
private function roundDigit(Number $number)
    {
        if ($number->isCloserToNext()) {
            return $this->add(
                $number->getIntegerPart(),
                $number->getIntegerRoundingMultiplier()
            );
        }

        return $this->add($number->getIntegerPart(), '0');
    }
852551
private static function parseFractionalPart($number)
    {
        if ('' === $number) {
            return $number;
        }

        for ($position = 0, $characters = strlen($number); $position < $characters; ++$position) {
            $digit = $number[$position];
            if (!isset(static::$numbers[$digit])) {
                throw new \InvalidArgumentException(
                    sprintf('Invalid fractional part %1$s. Invalid digit %2$s found', $number, $digit)
                );
            }
        }

        return $number;
    }
1218792
public static function format($number, $decimals = null, $decimalPoint = null,
                                  $thousandsSeparator = null)
    {
        if (is_null($decimals)) {
            $decimals = self::$decimals;
        }
        if (is_null($decimalPoint)) {
            $decimalPoint = self::$decimalPoint;
        }
        if (is_null($thousandsSeparator)) {
            $thousandsSeparator = self::$thousandsSeparator;
        }
        return number_format($number, $decimals, $decimalPoint, $thousandsSeparator);
    }
988138
public function numberToRomanNumerals(int $number): string
    {
        if ($number < 1) {
            // Cannot convert zero/negative numbers
            return (string) $number;
        }
        $roman = '';
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while ($number >= $key) {
                $roman  .= $value;
                $number -= $key;
            }
        }

        return $roman;
    }
309949
public static function numberFormat($number, $decimals = 0)
    {
        return is_numeric($number) ? number_format(
            $number,
            $decimals,
            __('lang_decimal_point'),
            __('lang_thousands_sep')
        ) : $number;
    }
515525
private function number_format($number, $decimal_precision = 0, $decimals_separator = '.', $thousands_separator = ',') {
        $number = explode('.', str_replace(' ', '', $number));
        $number[0] = str_split(strrev($number[0]), 3);
        $total_segments = count($number[0]);
        for ($i = 0; $i < $total_segments; $i++) {
            $number[0][$i] = strrev($number[0][$i]);
        }
        $number[0] = implode($thousands_separator, array_reverse($number[0]));
        if (!empty($number[1])) {
           $number[1] = round($number[1], $decimal_precision);
        }
        return implode($decimals_separator, $number);
    }
957395
public static function convert($number)
    {
        $number = preg_replace('/\,/i', '', $number);

        $number = preg_replace('/([^0-9\.\-])/i', '', $number);

        if (! is_numeric($number)) {
            return '0.00';
        }

        $isCents = (bool) preg_match('/^0.\d+$/', $number);

        return ($isCents ? '0' : null).number_format($number * 100., 0, '.', '');
    }
741199
private function roundDigit(Number $number)
    {
        if ($number->isCloserToNext()) {
            return bcadd(
                (string) $number,
                $number->getIntegerRoundingMultiplier(),
                0
            );
        }

        return bcadd((string) $number, '0', 0);
    }
95762
public function format($number) {
    if ((float) $number != $number) {
      throw new \InvalidArgumentException('Number has no valid float value.');
    }
    $sign = (int) ($number < 0);

    // Split the number in major and minor units, and make sure there is a
    // minor unit at all.
    $number = explode('.', abs($number));
    $number += array(
      self::MINOR => '',
    );

    $digits = array(
      str_split($number[self::MAJOR]),
      strlen($number[self::MINOR]) ? str_split($number[self::MINOR]) : array(),
    );

    $symbols = $this->cloneNumberPatternSymbols($this->symbols[$sign]);
    $this->process($symbols[$sign][self::MAJOR], $digits[self::MAJOR]);
    // Integer formatting defaults from right to left, but minor units should
    // be formatted from left to right, so reverse all data and results.
    $symbols_minor = array_reverse($symbols[$sign][self::MINOR]);
    $this->process($symbols_minor, array_reverse($digits[self::MINOR]));
    foreach ($symbols[$sign][self::MINOR] as $symbol) {
      if (!is_null($symbol->replacement)) {
        $symbol->replacement = strrev($symbol->replacement);
      }
    }

    // Prepare the output string.
    $output = array(
      self::MAJOR => '',
      self::MINOR => '',
    );
    foreach ($symbols[$sign] as $fragment => $fragment_symbols) {
      $this->replacePlaceholders($fragment_symbols);
      foreach ($fragment_symbols as $symbol) {
        $output[$fragment] .= !is_null($symbol->replacement) ? $symbol->replacement : $symbol->symbol;
      }
    }

    return $output[self::MAJOR] . $this->getReplacement(self::SYMBOL_SPECIAL_DECIMAL_SEPARATOR) . $output[self::MINOR];
  }
1250230
public function round($decimals = 2) {

		if(false === ('-' . intval($decimals) == '-' . $decimals)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($decimals)), E_USER_ERROR);
		}

		return $this -> convert(function($number, $decimals) {
			return round($number, $decimals);
		}, [$decimals]);
	}
447439
private function round($number)
    {
        if (null !== $this->precision && null !== $this->roundingMode) {
            // shift number to maintain the correct precision during rounding
            $roundingCoef = pow(10, $this->precision);
            $number *= $roundingCoef;

            switch ($this->roundingMode) {
                case \NumberFormatter::ROUND_CEILING:
                    $number = ceil($number);
                    break;
                case \NumberFormatter::ROUND_FLOOR:
                    $number = floor($number);
                    break;
                case \NumberFormatter::ROUND_UP:
                    $number = $number > 0 ? ceil($number) : floor($number);
                    break;
                case \NumberFormatter::ROUND_DOWN:
                    $number = $number > 0 ? floor($number) : ceil($number);
                    break;
                case \NumberFormatter::ROUND_HALFEVEN:
                    $number = round($number, 0, PHP_ROUND_HALF_EVEN);
                    break;
                case \NumberFormatter::ROUND_HALFUP:
                    $number = round($number, 0, PHP_ROUND_HALF_UP);
                    break;
                case \NumberFormatter::ROUND_HALFDOWN:
                    $number = round($number, 0, PHP_ROUND_HALF_DOWN);
                    break;
            }

            $number /= $roundingCoef;
        }

        return $number;
    }
603399
public static function benchScript($decimals = 3) : float
    {
        return (float) sprintf(
            '%0.'.(int) $decimals.'f',
            (microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])
        );
    }
671072
private static function localeNumber($number, int $decimal = 2): string
	{
		return Number::getNumber(self::prepareFloat($number), $decimal);
	}
883864
public static function ordinalize($number)
    {
        if (in_array(($number % 100), range(11, 13))) {
            return $number . 'th';
        }
        switch ($number % 10) {
            case 1:
                return $number . 'st';
            case 2:
                return $number . 'nd';
            case 3:
                return $number . 'rd';
            default:
                return $number . 'th';
        }
    }
966491
public function transform( $number, $decimals = 2 )
	{
		return number_format( $number, $decimals, $this->_dsep, $this->_tsep );
	}