8000 数字转中文大写存在bug · Issue #17 · Yurunsoft/ChineseUtil · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
数字转中文大写存在bug #17
Open
@liyiliang

Description

@liyiliang

` 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这种都转为零玖分,应该是负零玖分

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0