-
- Downloads
Number formatter Reports correct Decimal places for negative Numbers (#46104)
* Number formatter Reports correct Decimal places for negative Numbers Fixes #41640 Prior to this, the number formatter would get the incorrect number of decimal places for negative numbers. The way the decimal places count is derived works as follows: - convert number to a string - split the string on the separator (decimal, comma, whatever the instance has set) - destructure that split into [int decimal] - count decimal to get the number of decimals. That all works for positive numbers, but for negative numbers, the regex was just splitting on 'not digits', so we got an extra group due to the leading negative sign. This would incorrectly destructure the 'int' part of the number into the count, thus we would always get 1 instead of the correct value. This fixes it by just taking last instead of destructuring. * correct comparison to always use abs value in conditonal check * tiny incorrectness in the test
Loading
Please register or sign in to comment