本文整理汇总了PHP中Number::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Number::getValue方法的具体用法?PHP Number::getValue怎么用?PHP Number::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isEquals
public function isEquals(Number $n)
{
if ($this->getValue() == $n->getValue() && $this->isExtra() == $n->isExtra()) {
return true;
}
return false;
}
示例2: multiply
public function multiply(Number $precision, $scale = null)
{
$scale = $this->scale($scale);
$result = bcmul($this->value, $precision->getValue(), self::MAX_PRECISION);
$diff = $this->round($result, $scale);
return new self($diff, $scale);
}
示例3: lessThan
/**
* {@inheritDoc}
*/
public function lessThan(Number $n)
{
return $this->value <= $n->getValue();
}
示例4: bcCalc
/**
* @param $name
* @param $args
* @return String
*/
protected function bcCalc($name, $args)
{
$value = current($args);
if ($value instanceof number\Percentage) {
switch ($name) {
case 'bcmul':
case 'bcdiv':
$value->bcdiv(100)->bcmul($this->getValue());
break;
default:
$value = $value->of($this);
break;
}
} elseif (!$value instanceof Number) {
if (is_numeric($value)) {
$value = new Number($value);
} else {
trigger_error('BC Functions must be compared with another Number or a valid number');
}
}
if ($name == 'bcdiv' && $value->getValue() == 0) {
$result = 0;
} else {
$result = $name($this->getValue(), $value->getValue(), $this->getPrecision());
}
return $result;
}
示例5: testValueIsCastedToFloatInConstructor
/**
* @dataProvider providerValueIsCastedToFloatInConstructor
*/
public function testValueIsCastedToFloatInConstructor($expectedValue, Number $number)
{
$this->assertInternalType('float', $number->getValue());
$this->assertSame($expectedValue, $number->getValue());
}
示例6: Number
<?php
require_once 'Number.php';
if (isset($_POST['num'])) {
if (isset($_POST['dowhat'])) {
$num = new Number(intval($_POST['num']));
switch ($_POST['dowhat']) {
case 'nth':
$nthPrime = $num->getNthPrime();
$enders = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th');
if ($num->getValue() % 100 >= 11 && $num->getValue() % 100 <= 13) {
$abbreviation = 'th';
} else {
$abbreviation = $enders[$num->getValue() % 10];
}
echo "The " . $num->getValue() . $abbreviation . " prime number is " . $nthPrime;
break;
case 'allPrimes':
if ($num->getPrimesBelowN()) {
$handle = fopen('sieveResults.txt', 'r') or die("Couldn't do it captain!");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
}
fclose($handle);
}
break;
case 'isPrime':
echo $num->isPrime();