当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale_Math::isBcmathDisabled方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:37,代码来源:MathTest.php


注:本文中的Zend_Locale_Math::isBcmathDisabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。