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


PHP Math::divide方法代码示例

本文整理汇总了PHP中Math::divide方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::divide方法的具体用法?PHP Math::divide怎么用?PHP Math::divide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Math的用法示例。


在下文中一共展示了Math::divide方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testError

 public function testError()
 {
     $math = new Math();
     // no input
     try {
         $math->add();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to add', $e->getMessage());
     }
     // no input
     try {
         $math->subtract();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to subtract', $e->getMessage());
     }
     // no input
     try {
         $math->multiply();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to multiply', $e->getMessage());
     }
     // no input
     try {
         $math->divide();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to divide', $e->getMessage());
     }
     //invalid input
     try {
         $math->setA('adf');
     } catch (\Exception $e) {
         $this->assertEquals('Invalid input', $e->getMessage());
     }
 }
开发者ID:soycaringal,项目名称:gae-test,代码行数:34,代码来源:function.php

示例2: start

 /**
  * PhysicShot::start()
  * Start the system
  * @return
  */
 public function start()
 {
     //se il danno è zero non serve.
     if ($this->damage == 0) {
         return;
     }
     //se gli scudi sono disattivati,per evitare la divisione per zero
     if ($this->fighters->getShieldCellValue() == 0) {
         $this->inflict();
         return;
     }
     $currentCellsCount = $this->fighters->getCurrentShield();
     if (USE_HITSHIP_LIMITATION) {
         // bisogna tenere solo i colpi neccessari alla distruzione di tutti gli scudi
         $currentCellsCount = floor($currentCellsCount * $this->getHitShips() / $this->fighters->getCount());
     }
     $dv = Math::divide(new Number($this->damage), new Number($this->fighters->getShieldCellValue()), true);
     $cellsDestroyedInOneShot = $dv->result;
     $bouncedDamageForOneShot = $dv->rest;
     echo "cellvalue=" . $this->fighters->getShieldCellValue() . "<br>cellsDestroyedInOneShot={$cellsDestroyedInOneShot}<br>bouncedDamageForOneShot={$bouncedDamageForOneShot}<br>currentCellsCount={$currentCellsCount}<br>";
     $this->bounce($currentCellsCount, $cellsDestroyedInOneShot, $bouncedDamageForOneShot);
     $this->assorb($currentCellsCount, $cellsDestroyedInOneShot);
     $this->inflict();
 }
开发者ID:Gritch69,项目名称:XG-Project,代码行数:29,代码来源:PhysicShot.php

示例3: getShotsFiredByAllToOne

 public function getShotsFiredByAllToOne($real = false)
 {
     $num = new Number($this->getAttackerTotalShots());
     $denum = new Number($this->defenderFleet->getTotalCount());
     return Math::divide($num, $denum, $real);
 }
开发者ID:athk,项目名称:XG-Proyect-v3.x.x,代码行数:6,代码来源:Fire.php


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