Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Duplicate
-
Affects Version/s: 1.9.6
-
Fix Version/s: 1.10.0
-
Component/s: Zend_Measure
-
Labels:None
Description
Affected method Zend_Measure_Abstract::setType.
This code determine precision based using amount of signs after point, but it is wrong behaviour.
if (strpos($this->_value, '.') !== false) { $prec = strlen(substr($this->_value, strpos($this->_value, '.') + 1)); }
and later it round value using this precision
$this->_value = Zend_Locale_Math::round($value, $prec);
There is no way to set precision for calculation.
So, for instance, I want to convert lots of bytes to MiB
$size = new Zend_Measure_Binary(44848484888);
echo $size->convertTo(Zend_Measure_Binary::MEBIBYTE); // 42,771.0 MiB and default precision is 2
But it should be 44848484888/(1024*1024) = 42770.848167419
So, I have to get 42,770.85 MiB.
Possible work around: Create object in special way
$size = new Zend_Measure_Binary(strval(44848484888) . '.00'); // number of digits after point should be equal to you precision.
Duplication of
ZF-8009ZF-8009