ChineseUtil icon indicating copy to clipboard operation
ChineseUtil copied to clipboard

数字转中文大写存在bug

Open liyiliang opened this issue 4 years ago • 0 comments

` public function toChinese($number, $options = []) { if (!static::verifyNumber($number)) { throw new \InvalidArgumentException(sprintf('%s is not a valied number', $number)); }

    list($integer, $decimal) = explode('.', $number . '.');

    if ($integer < 0)
    {
        $pom = static::$numberMap['-'];
        $integer = abs($integer);
    }
    else
    {
        $pom = '';
    }

    if ($integer > 0)
    {
        return $pom . static::parseInteger($integer, $options) . static::parseDecimal($decimal, $options);
    }
    elseif (!$decimal)
    {
        return static::$numberMap[0] . static::$moneyUnitMap[0][0];
    }
    else
    {
        return $pom . static::parseDecimal($decimal, $options);
    }
}`

判断正负的时候应该使用number来判断。现在 -0.09这种都转为零玖分,应该是负零玖分

liyiliang avatar Dec 02 '21 07:12 liyiliang