Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2015-10-12 04:50:38 +0300
committermattab <matthieu.aubry@gmail.com>2015-10-12 04:50:51 +0300
commit9ced7c48b4a710428bd7e818b8e919dd13e7944a (patch)
tree67356f7eaa9160b3b46fec8f8bd374ab0d3dfd7f /core
parent9b71446cd183946a5a1d6b98368346aac3fbc036 (diff)
Fixes https://github.com/piwik/piwik/issues/8966
Diffstat (limited to 'core')
-rw-r--r--core/NumberFormatter.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/NumberFormatter.php b/core/NumberFormatter.php
index 4ce2058bc6..4e2d376314 100644
--- a/core/NumberFormatter.php
+++ b/core/NumberFormatter.php
@@ -114,7 +114,7 @@ class NumberFormatter extends Singleton
if (empty($positivePatter) || empty($negativePattern)) {
list($positivePattern, $negativePattern) = $this->parsePattern($this->patternNumber);
}
- $negative = (bccomp('0', $value, 12) == 1);
+ $negative = $this->isNegative($value);
$pattern = $negative ? $negativePattern : $positivePattern;
return $this->formatNumberWithPattern($pattern, $value, $maximumFractionDigits, $minimumFractionDigits);
@@ -140,7 +140,7 @@ class NumberFormatter extends Singleton
return $value;
}
- $negative = (bccomp('0', $value, 12) == 1);
+ $negative = $this->isNegative($value);
$pattern = $negative ? $negativePattern : $positivePattern;
return $this->formatNumberWithPattern($pattern, $newValue, $maximumFractionDigits, $minimumFractionDigits);
@@ -185,7 +185,7 @@ class NumberFormatter extends Singleton
return $value;
}
- $negative = (bccomp('0', $value, 12) == 1);
+ $negative = $this->isNegative($value);
$pattern = $negative ? $negativePattern : $positivePattern;
if ($newValue == round($newValue)) {
@@ -227,7 +227,7 @@ class NumberFormatter extends Singleton
}
// Ensure that the value is positive and has the right number of digits.
- $negative = (bccomp('0', $value, 12) == 1);
+ $negative = $this->isNegative($value);
$signMultiplier = $negative ? '-1' : '1';
$value = bcdiv($value, $signMultiplier, $maximumFractionDigits);
// Split the number into major and minor digits.
@@ -292,4 +292,13 @@ class NumberFormatter extends Singleton
);
return strtr($value, $replacements);
}
+
+ /**
+ * @param $value
+ * @return bool
+ */
+ protected function isNegative($value)
+ {
+ return $value < 0;
+ }
} \ No newline at end of file