We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NP.times('0.1', 100); // 10 NP.times('0.1 ', 100); // 1
第一种情况是正常的计算,第二种情况计算结果异常,原因是 '0.1 ' 中末尾包含空格。
调试发现 NP 在计算参数小数位数之前没有将其先转换为数字再计算,因此空格也算在小数位数之中并且空格在进行运算的时候不会报错,因此导致 NP 静默错误。
NP 是否需要处理参数为字符串的情况?
The text was updated successfully, but these errors were encountered:
字符串输入运算已经支持了,我的个人理解啊,像这种本身输入就不是一个合法的数字字符串,是没必要考虑的,这种非法的字符串输入应该在运算前就限制住,保证我在运算的时候肯定是合法的输入,就像undefined、null和其他非法字符串一样本身就不应该参与运算
Sorry, something went wrong.
确实库只是保证根据输入返回给你正确的结果,不应该干与计算无关的事情,这才叫纯粹的库。
No branches or pull requests
第一种情况是正常的计算,第二种情况计算结果异常,原因是 '0.1 ' 中末尾包含空格。
调试发现 NP 在计算参数小数位数之前没有将其先转换为数字再计算,因此空格也算在小数位数之中并且空格在进行运算的时候不会报错,因此导致 NP 静默错误。
NP 是否需要处理参数为字符串的情况?
The text was updated successfully, but these errors were encountered: