Skip to content

Commit 1893dcc

Browse files
committed
Fixed percentage in Number.add().
1 parent 2fbc26f commit 1893dcc

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- fixed: `F.cors()`
5353
- fixed: WebSocket initialization (critical)
5454
- fixed: Mail sender (problem with ZOHO SMTP)
55+
- fixed: `Number.add()` problem with percentage
5556

5657
- renamed: event `route-add` to `route`
5758
- renamed: `F.versionNode` to `F.version_node`

utils.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,20 +3560,19 @@ Number.prototype.add = function(value, decimals) {
35603560
isPercentage = true;
35613561

35623562
if (is) {
3563-
var tmp = ((value.parseFloat() / 100) + 1);
3564-
3563+
var val = value.parseFloat();
35653564
switch (first) {
35663565
case 42:
3567-
num = this * (this * tmp);
3566+
num = this * ((this / 100) * val);
35683567
break;
35693568
case 43:
3570-
num = this * tmp;
3569+
num = this + ((this / 100) * val);
35713570
break;
35723571
case 45:
3573-
num = this / tmp;
3572+
num = this - ((this / 100) * val);
35743573
break;
35753574
case 47:
3576-
num = this / (this / tmp);
3575+
num = this / ((this / 100) * val);
35773576
break;
35783577
}
35793578
return decimals !== undefined ? num.floor(decimals) : num;

0 commit comments

Comments
 (0)