保留数字小数位数(不会四舍五入)
@param number $number 数字
@param int $digit 保留小数位数,默认2位
@return bool|float 成功返回float,失败返回false[注意参数错误也会返回false]
773516
public function keep_decimals($number, $digit = 2)
    {
        //不是数字
        if (!is_numeric($number)) {
            return false;
        }
        //保留小数位数必须是数组,并且不能小于0
        if (!is_numeric($digit) || $digit < 0) {
            return false;
        }
        //以小数点分割
        $arr = explode('.', $number);
        //整数部分
        $integer = $arr[0];
        //小数部分
        $decimals = isset($arr[1]) ? "{$arr[1]}" : '';
        //小数位数
        $decimalsLen = strlen($decimals);
        //保留的小数部分
        $decimalsKeep = '';
        //小数位数>=保留小数位数
        if ($decimalsLen >= $digit) {
            $decimalsKeep = substr($decimals, 0, $digit);
        } else {
            $decimalsKeep = str_repeat('0', $digit - $decimalsLen);
            $decimalsKeep = "{$decimals}$decimalsKeep";
        }
        $keep_arr = array(
            $integer,
            $decimalsKeep
        );
        $numberKeep = implode('.', $keep_arr);
        //删除右边的小数点"."
        $numberKeep = rtrim($numberKeep, '.');
        return $numberKeep;
    }
1225090
protected function _calculateRefMod10v5($number)
    {
        $number = preg_replace("/\D/", "", $number);

        // The seed number needs to be numeric
        if (!is_numeric($number)) {
            return false;
        }

        // Must be a positive number
        if ($number <= 0) {
            return false;
        }

        // Get the length of the seed number
        $length = strlen($number);

        $total = 0;

        // For each character in seed number, sum the character multiplied by its one
        // based array position (instead of normal PHP zero based numbering)
        for ($i = 0; $i < $length; $i++) {
            $total += $number{$i} * ($i + 1);
        }

        // The check digit is the result of the sum total from above mod 10
        $checkDigit = fmod($total, 10);

        // Return the original seed plus the check digit
        return $number . $checkDigit;
    }
833855
public function number($number, $decimals = 0)
    {
        if (!$this->localizer) {
            return number_format($number, $decimals);
        }

        return $this->localizer->number($number, $decimals);
    }
172345
protected function modulo10($number)
    {
        $next = 0;
        for ($i=0; $i < strlen($number); $i++) {
            $next = $this->moduloTable[($next + intval(substr($number, $i, 1))) % 10];
        }

        return (10 - $next) % 10;
    }
1237296
public static function bytesFrom($number) {
        if (!$number) {
            return 0;

        } else if (is_numeric($number)) {
            return $number;
        }

        $number = trim((string) $number);
        $sizes = array(
            'k|kb|ki|kib' => 10,
            'm|mb|mi|mib' => 20,
            'g|gb|gi|gib' => 30,
            't|tb|ti|tib' => 40,
            'p|pb|pi|pib' => 50,
            'e|eb|ei|eib' => 60,
            'z|zb|zi|zib' => 70,
            'y|yb|yi|yib' => 80,
            'b' => 0
        );

        foreach ($sizes as $format => $pow) {
            if (preg_match('/^([0-9\.]+)(' . $format . ')$/i', $number, $matches)) {
                return (((float) $matches[1]) * pow(2, $pow));
            }
        }

        return null;
    }
400093
public function digit($field)
    {
        return (ctype_digit((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__);
    }
883062
public static function ceil($number)
    {
        if (self::compare($number, 0) == 1) {
            $result = bcadd($number, '1', 0);
        } else {
            $result = bcadd($number, '0', 0);
        }

        return $result;
    }
400574
public static function num2rmb($number = 0, $int_unit = '元', $is_round = true, $is_extra_zero = false)
    {
        // 将数字切分成两段
        $parts = explode('.', $number, 2);
        $int = isset($parts[0]) ? strval($parts[0]) : '0';
        $dec = isset($parts[1]) ? strval($parts[1]) : '';

        // 如果小数点后多于2位，不四舍五入就直接截，否则就处理
        $dec_len = strlen($dec);
        if (isset($parts[1]) && $dec_len > 2) {
            $dec = $is_round
                ? substr(strrchr(strval(round(floatval("0.".$dec), 2)), '.'), 1)
                : substr($parts[1], 0, 2);
        }

        // 当number为0.001时，小数点后的金额为0元
        if (empty($int) && empty($dec)) {
            return '零';
        }

        // 定义
        $chs = array('0','壹','贰','叁','肆','伍','陆','柒','捌','玖');
        $uni = array('','拾','佰','仟');
        $dec_uni = array('角', '分');
        $exp = array('', '万');
        $res = '';

        // 整数部分从右向左找
        for ($i = strlen($int) - 1, $k = 0; $i >= 0; $k++) {
            $str = '';
            // 按照中文读写习惯，每4个字为一段进行转化，i一直在减
            for ($j = 0; $j < 4 && $i >= 0; $j++, $i--) {
                $u = $int{$i} > 0 ? $uni[$j] : ''; // 非0的数字后面添加单位
                $str = $chs[$int{$i}] . $u . $str;
            }
            //echo $str."|".($k - 2)."<br>";
            $str = rtrim($str, '0');// 去掉末尾的0
            $str = preg_replace("/0+/", "零", $str); // 替换多个连续的0
            if (!isset($exp[$k])) {
                $exp[$k] = $exp[$k - 2] . '亿'; // 构建单位
            }
            $u2 = $str != '' ? $exp[$k] : '';
            $res = $str . $u2 . $res;
        }

        // 如果小数部分处理完之后是00，需要处理下
        $dec = rtrim($dec, '0');

        // 小数部分从左向右找
        if (!empty($dec)) {
            $res .= $int_unit;

            // 是否要在整数部分以0结尾的数字后附加0，有的系统有这要求
            if ($is_extra_zero) {
                if (substr($int, -1) === '0') {
                    $res.= '零';
                }
            }

            for ($i = 0, $cnt = strlen($dec); $i < $cnt; $i++) {
                $u = $dec{$i} > 0 ? $dec_uni[$i] : ''; // 非0的数字后面添加单位
                $res .= $chs[$dec{$i}] . $u;
            }
            $res = rtrim($res, '0');// 去掉末尾的0
            $res = preg_replace("/0+/", "零", $res); // 替换多个连续的0
        } else {
            $res .= $int_unit . '整';
        }
        return $res;
    }
1321980
public static int parseInt(String number) throws NumberFormatException {
		if (StrUtil.isBlank(number)) {
			return 0;
		}

		// 对于带小数转换为整数采取去掉小数的策略
		number = StrUtil.subBefore(number, CharUtil.DOT, false);
		if (StrUtil.isEmpty(number)) {
			return 0;
		}

		if (StrUtil.startWithIgnoreCase(number, "0x")) {
			// 0x04表示16进制数
			return Integer.parseInt(number.substring(2), 16);
		}

		return Integer.parseInt(removeNumberFlag(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, '.', '');
    }
89463
private static function executeStep2($number) {
        $byteArray = str_pad(self::bcdecuc($number), 13, chr(0), STR_PAD_LEFT);

        $generatorPolynomial = 0x0f35;
        $frameCheckSequence = 0x07ff;
        $data = 0;
        $byteIndex = 0;
        $bit = 0;

        $data = (ord($byteArray[$byteIndex]) << 5) & 0xffff;
        for ($bit = 2; $bit < 8; $bit++) {
            if (($frameCheckSequence ^ $data) & 0x400) {
                $frameCheckSequence = ($frameCheckSequence << 1) ^ $generatorPolynomial;
            } else {
                $frameCheckSequence = ($frameCheckSequence << 1);
            }

            $frameCheckSequence &= 0x7ff;
            $data <<= 1;
            $data &= 0xffff;
        }

        for ($byteIndex = 1; $byteIndex < 13; $byteIndex++) {
            $data = (ord($byteArray[$byteIndex]) << 3) & 0xffff;
            for ($bit = 0; $bit < 8; $bit++) {
                if (($frameCheckSequence ^ $data) & 0x0400) {
                    $frameCheckSequence = ($frameCheckSequence << 1) ^ $generatorPolynomial;
                } else {
                    $frameCheckSequence = ($frameCheckSequence << 1);
                }

                $frameCheckSequence &= 0x7ff;
                $data <<= 1;
                $data &= 0xffff;
            }
        }

        return $frameCheckSequence;
    }
117282
public function number($number, $decimals = null)
    {
        return number_format(
            (float) $number,
            $decimals,
            $this->getSymbol(self::DECIMAL_MARK),
            $this->getSymbol(self::THOUSANDS_SEPARATOR)
        );
    }
127239
function (number, digits) {
    if (typeof number !== "number") { throw "not a number: " + number; }
    var s = number.toString();
    if (number.length > digits) {
      return number.substr(number.length - digits, number.length);
    }
    while (s.length < digits) {
      s = '0' + s;
    }
    return s;
  }
63386
private static function size($number, int $decimal = 2, bool $binary = false)
	{
		return Number::size(self::prepareFloat($number), $decimal, $binary);
	}
797183
public static function isInt($int)
    {
        return (is_string($int) || is_int($int) || is_float($int)) &&
            ctype_digit((string)$int);
    }
165169
private function showDigitsGroup($number, $last = false)
    {
        $ret = '';

        $units = $number % 10;
        $tens = (int) ($number / 10) % 10;
        $hundreds = (int) ($number / 100) % 10;

        if ($hundreds) {
            if ($hundreds > 1) {
                $ret .= BelgianDictionary::$digits[$hundreds] . BelgianDictionary::$wordSeparator . BelgianDictionary::$miscNumbers[100];
                if ($last && !$units && !$tens) {
                    $ret .= BelgianDictionary::$pluralSuffix;
                }
            } else {
                $ret .= BelgianDictionary::$miscNumbers[100];
            }
            $ret .= BelgianDictionary::$wordSeparator;
        }

        if ($tens) {
            if ($tens === 1) {
                if ($units <= 6) {
                    $ret .= BelgianDictionary::$miscNumbers[10 + $units];
                } else {
                    $ret .= BelgianDictionary::$miscNumbers[10] . '-' . BelgianDictionary::$digits[$units];
                }
                $units = 0;
            } elseif ($tens === 8) {
                $ret .= BelgianDictionary::$digits[4] . BelgianDictionary::$dash . BelgianDictionary::$miscNumbers[20];
                $resto = $tens * 10 + $units - 80;
                if ($resto) {
                    $ret .= BelgianDictionary::$dash;
                    $ret .= $this->showDigitsGroup($resto);
                    $units = 0;
                } else {
                    $ret .= BelgianDictionary::$pluralSuffix;
                }
            } else {
                $ret .= BelgianDictionary::$miscNumbers[$tens * 10];
            }
        }

        if ($units) {
            if ($tens) {
                if ($units === 1) {
                    $ret .= BelgianDictionary::$wordSeparator . BelgianDictionary::$and . BelgianDictionary::$wordSeparator;
                } else {
                    $ret .= BelgianDictionary::$dash;
                }
            }
            $ret .= BelgianDictionary::$digits[$units];
        }

        return rtrim($ret, BelgianDictionary::$wordSeparator);
    }
1250999
public static function getCheckDigit(string $number) : int
    {
        if (! ctype_digit($number)) {
            throw new \InvalidArgumentException('The number must be a string of digits');
        }

        $checksum = self::checksum($number . '0');

        return ($checksum === 0) ? 0 : 10 - $checksum;
    }