本文整理汇总了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());
}
}
示例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();
}
示例3: getShotsFiredByAllToOne
public function getShotsFiredByAllToOne($real = false)
{
$num = new Number($this->getAttackerTotalShots());
$denum = new Number($this->defenderFleet->getTotalCount());
return Math::divide($num, $denum, $real);
}