mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2025-06-13 12:54:17 +00:00
BUG for call from Number.prototype.anyMethod
Expect to use Decimal.prototype.toFixed replace the original method
```javascript
(function() {
var originalToFixed = Number.prototype.toFixed;
Number.prototype.toFixed = function(decimal) {
if (window.Decimal && Decimal.prototype.toFixed) {
return new Decimal(this).toFixed(decimal);
} else {
return originalToFixed(this, decimal);
}
};
)();
```
TestCode
(2).toFixed(2);
will be run to line 4340 thrown error '[DecimalError] Invalid argument: 2'
because line 4290 test typeof v returned 'object'
This commit is contained in:
parent
5a6e1384d8
commit
07b8ae1437
@ -4289,7 +4289,7 @@
|
||||
|
||||
t = typeof v;
|
||||
|
||||
if (t === 'number') {
|
||||
if (t === 'number' || v instanceof Number) {
|
||||
if (v === 0) {
|
||||
x.s = 1 / v < 0 ? -1 : 1;
|
||||
x.e = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user