diff --git a/core/NumberFormatter.php b/core/NumberFormatter.php index 4e2d376314294cd802e30cb90fbe6baea89fff7d..ad030400f4ad77ac987dce0d430c8a7df6cc9827 100644 --- a/core/NumberFormatter.php +++ b/core/NumberFormatter.php @@ -229,7 +229,8 @@ class NumberFormatter extends Singleton // Ensure that the value is positive and has the right number of digits. $negative = $this->isNegative($value); $signMultiplier = $negative ? '-1' : '1'; - $value = bcdiv($value, $signMultiplier, $maximumFractionDigits); + $value = $value / $signMultiplier; + $value = round($value, $maximumFractionDigits); // Split the number into major and minor digits. $valueParts = explode('.', $value); $majorDigits = $valueParts[0]; diff --git a/tests/PHPUnit/Integration/NumberFormatterTest.php b/tests/PHPUnit/Integration/NumberFormatterTest.php index e2ac454b4e56dbb0141bae10223db9ea85c9e017..981b289f2b29495dfc9ca54a1c8db586f3333f08 100644 --- a/tests/PHPUnit/Integration/NumberFormatterTest.php +++ b/tests/PHPUnit/Integration/NumberFormatterTest.php @@ -57,8 +57,8 @@ class NumberFormatterTest extends \PHPUnit_Framework_TestCase array('be', 51239.56, 3, 0, '51 239,56'), array('de', 51239.56, 3, 0, '51.239,56'), array('bn', 152551239.56, 3, 0, '15,25,51,239.56'), - array('hi', 152551239.56, 0, 0, '15,25,51,239'), - array('lt', -152551239.56, 0, 0, '−152 551 239'), + array('hi', 152551239.56, 0, 0, '15,25,51,240'), + array('lt', -152551239.56, 0, 0, '−152 551 240'), ); } @@ -80,7 +80,7 @@ class NumberFormatterTest extends \PHPUnit_Framework_TestCase array('en', -5, 0, 3, '-5%'), array('en', 5.299, 0, 0, '5%'), array('en', 5.299, 3, 0, '5.299%'), - array('en', -50, 3, 3, '-50.000%'), + array('en', -50, 3, 3, '-50%'), array('en', 5000, 0, 0, '5,000%'), array('en', +5000, 0, 0, '5,000%'), array('en', 5000000, 0, 0, '5,000,000%'), @@ -91,8 +91,8 @@ class NumberFormatterTest extends \PHPUnit_Framework_TestCase array('be', 51239.56, 3, 0, '51 239,56 %'), array('de', 51239.56, 3, 0, '51.239,56 %'), array('bn', 152551239.56, 3, 0, '15,25,51,239.56%'), - array('hi', 152551239.56, 0, 0, '15,25,51,239%'), - array('lt', -152551239.56, 0, 0, '−152 551 239 %'), + array('hi', 152551239.56, 0, 0, '15,25,51,240%'), + array('lt', -152551239.56, 0, 0, '−152 551 240 %'), ); }