本文整理汇总了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));
}
}