本文整理匯總了PHP中Zend_Locale_Math::isBcmathDisabled方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Locale_Math::isBcmathDisabled方法的具體用法?PHP Zend_Locale_Math::isBcmathDisabled怎麽用?PHP Zend_Locale_Math::isBcmathDisabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Locale_Math
的用法示例。
在下文中一共展示了Zend_Locale_Math::isBcmathDisabled方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testRound
/**
* test round()
* expect string when BCMath extension is enabled
*/
public function testRound()
{
$rounder = array('0.477051' => -12, '513695.36425' => 1, '89.85' => 4, '533.506' => 3, '0.376139' => -2, '1784212419' => -9, '447878.429296' => -11, '79.31' => -2, '941.543' => -5, '0.396850' => -10, '425271509' => 10, '220820.93233' => -2, ' ... //#注:代碼行過長, 已省略後續字符...
if (!Zend_Locale_Math::isBcmathDisabled()) {
// If no BCMath extension, the round below falls through to PHP's round(),
// which actually produces incorrect results, and fails these tests.
// There are many such examples ...
$this->assertEquals(Zend_Locale_Math::round('56055.18115', 4), '56055.1812');
$this->assertEquals(Zend_Locale_Math::round('639.795', 2), '639.80');
$this->assertEquals(Zend_Locale_Math::round('267.835', 2), '267.84');
$this->assertEquals(Zend_Locale_Math::round('0.302515', 5), '0.30252');
$this->assertEquals(Zend_Locale_Math::round('0.36665', 4), '0.3667');
}
$this->assertEquals(Zend_Locale_Math::round('3.4'), '3');
$this->assertEquals(Zend_Locale_Math::round('3.4'), round(3.4));
$this->assertEquals(Zend_Locale_Math::round('3.5'), '4');
$this->assertEquals(Zend_Locale_Math::round('3.5'), round(3.5));
$this->assertEquals(Zend_Locale_Math::round('3.6'), '4');
$this->assertEquals(Zend_Locale_Math::round('3.6'), round(3.6));
$this->assertEquals(Zend_Locale_Math::round('3.6', 0), '4');
$this->assertEquals(Zend_Locale_Math::round('3.6', 0), round(3.6, 0));
$this->assertEquals(Zend_Locale_Math::round('1.95583', 2), '1.96');
$this->assertEquals(Zend_Locale_Math::round('1.95583', 2), round(1.95583, 2));
$this->assertEquals(Zend_Locale_Math::round('1241757', -3), '1242000');
$this->assertEquals(Zend_Locale_Math::round('1241757', -3), round(1241757, -3));
$this->assertEquals(Zend_Locale_Math::round('5.045', 2), '5.05');
$this->assertEquals(Zend_Locale_Math::round('5.045', 2), round(5.045, 2));
$this->assertEquals(Zend_Locale_Math::round('5.055', 2), '5.06');
$this->assertEquals(Zend_Locale_Math::round('5.055', 2), round(5.055, 2));
foreach ($rounder as $val => $precision) {
$this->assertEquals((string) Zend_Locale_Math::round($val, $precision), (string) round($val, $precision));
}
}