本文整理汇总了PHP中Math类的典型用法代码示例。如果您正苦于以下问题:PHP Math类的具体用法?PHP Math怎么用?PHP Math使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Math类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testSub
public function testSub()
{
$math = new Math();
//Success
$this->assertEquals(3, $math->sub(8, 5));
//Success
$this->assertEquals(3, $math->sub(9, 6));
}
开发者ID:atmarkcafe,项目名称:offshoredepart,代码行数:8,代码来源:MathTest.php
示例2: testMath
function testMath()
{
$math = new Math();
$coord1 = $math->GetGeoShortestDistance(40.6657, -80.3521, 32.7631, -96.7984);
$this->assertTrue(($coord1 == 1708.05), "Distance 1 received");
$coord2 = $math->GetGeoShortestDistance(50.95, 30.68, 50, 36.25);
$this->assertTrue(($coord2 == 407.83), "Distance 2 received");
}
开发者ID:rchicoria,项目名称:epp-drs,代码行数:10,代码来源:tests.php
示例3: cliParser
public static function cliParser($value)
{
try {
if (Validator::isValidCli($value)) {
$math = new Math();
$result = $math->runMath($value);
}
return iCalc::iHeaderMessage . iCalc::iMathMessage . "{$value[1]} {$value[2]} {$value[3]}" . iCalc::iRespMessage . "{$result}" . iCalc::iEndLineMessage;
} catch (CalculatorException $calcEx) {
$calcEx->getMessage(iCalc::iParserErrMessage);
}
}
开发者ID:marcosptf,项目名称:phpCalc,代码行数:12,代码来源:Parser.php
示例4: indexTables
public function indexTables($a, $b, $hdr)
{
$this->ia->indexTable($a, $hdr);
$this->ib->indexTable($b, $hdr);
$this->hdr = $hdr;
$good = 0;
if (null == $this->ia->items) {
throw new HException('null iterable');
}
$__hx__it = $this->ia->items->keys();
while ($__hx__it->hasNext()) {
unset($key);
$key = $__hx__it->next();
$item_a = $this->ia->items->get($key);
$spot_a = $item_a->lst->length;
$item_b = $this->ib->items->get($key);
$spot_b = 0;
if ($item_b !== null) {
$spot_b = $item_b->lst->length;
}
if ($spot_a === 1 && $spot_b === 1) {
$good++;
}
unset($spot_b, $spot_a, $item_b, $item_a);
}
$this->quality = $good / Math::max(1.0, $a->get_height());
}
开发者ID:paulfitz,项目名称:daff-php,代码行数:27,代码来源:IndexPair.class.php
示例5: printWD
public static function printWD($wd)
{
if ($wd) {
return Math::wd_round($wd) . ' ' . Yii::app()->params['water_demand_unit'];
}
return '0 ' . Yii::app()->params['water_demand_unit'];
}
开发者ID:Gnafu,项目名称:wiz,代码行数:7,代码来源:Utilities.php
示例6: particularidade
public function particularidade($object)
{
//pr($object->Data);
$digAgConta = $object->Data['Agencia'] . $object->Data['Conta'];
$digAgContaCartNNum = $object->Data['Agencia'] . $object->Data['Conta'] . $object->Data['Carteira'] . $object->Data['NossoNumero'];
$object->Data['DigitoAgContaCarteiraNNum'] = Math::Mod10($digAgContaCartNNum);
$object->Data['DigitoAgConta'] = Math::Mod10($digAgConta);
}
开发者ID:nunomazer,项目名称:PHP-Object-Boleto,代码行数:8,代码来源:Itau.php
示例7: max
static function max($a, $b)
{
if (!Math::isNaN($b)) {
return max($a, $b);
} else {
return Math::$NaN;
}
}
开发者ID:sp-ruben-simon,项目名称:daff-php,代码行数:8,代码来源:Math.class.php
示例8: testBcMath
/**
* @requires extension bcmath
* @runInSeparateProcess
*/
public function testBcMath()
{
if (!extension_loaded('bcmath')) {
$this->markTestSkipped('The Bcmath extension is NOT loaded! You must enable it to run this test');
} elseif (extension_loaded('gmp')) {
$this->markTestSkipped('The GMP extension is loaded! You must remove it to run this test');
}
Math::add("3324234234234234234", "3324234234234234234");
$this->assertEquals(new BcEngine(), Math::getEngine());
}
开发者ID:bitpay,项目名称:php-client,代码行数:14,代码来源:MathTest.php
示例9: 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
示例10: store
public function store()
{
$validator = Validator::make(Input::all(), ['paste' => 'required']);
if ($validator->fails()) {
return Redirect::route('create')->withErrors($validator);
}
try {
$paste = Paste::create(['paste' => Input::get('paste'), 'fork_of' => Input::get('fork', null)]);
} catch (Exception $e) {
return Redirect::route('create')->withErrors($e->getMessage());
}
return Redirect::route('show', Math::to_base($paste->id));
}
开发者ID:GitMsgr,项目名称:pastes,代码行数:13,代码来源:PasteController.php
示例11: base26
public function base26($num)
{
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if ($num < 0) {
return "-";
}
$out = "";
do {
$out = _hx_string_or_null($out) . _hx_string_or_null(_hx_char_at($alpha, _hx_mod($num, 26)));
$num = Math::floor($num / 26) - 1;
} while ($num >= 0);
return $out;
}
开发者ID:paulfitz,项目名称:daff-php,代码行数:13,代码来源:Unit.class.php
示例12: validate
protected function validate()
{
$start = Math::getNormalizedPosition($this->account, $this->start);
$end = Math::getNormalizedPosition($this->account, $this->end);
$length = abs($end - $start) + 1;
$this->position = $start;
$stepping = $end - $start < 0 ? -1 : +1;
for ($this->i = 0; $this->i < $length; $this->i++) {
$this->number = (int) $this->account[$this->position];
$this->iterationStep();
$this->position += $stepping;
}
}
开发者ID:jschaedl,项目名称:bav,代码行数:13,代码来源:Iteration.php
示例13: __construct
public function __construct($baseURL, $number_of_results, $results_per_page)
{
if (!php_Boot::$skip_constructor) {
if ($results_per_page <= 0) {
throw new HException(new system_base_General_error(" results per page must be 1 or larger", 500, _hx_anonymous(array("fileName" => "Paginator.hx", "lineNumber" => 37, "className" => "system.base.Paginator", "methodName" => "new"))));
}
$full_pages = Math::floor($number_of_results / $results_per_page);
$spill_pages = system_base_Paginator_0($this, $baseURL, $full_pages, $number_of_results, $results_per_page);
$this->current_links = null;
$this->base_url = $baseURL;
$this->total_pages = $full_pages + $spill_pages;
}
}
开发者ID:marcdraco,项目名称:Webrathea,代码行数:13,代码来源:Paginator.class.php
示例14: divide
public static function divide(Number $num, Number $denum, $real = false)
{
if ($real) {
if ($denum->result == 0) {
throw new Exception('denum is zero');
}
$shots = floor($num->result / $denum->result);
$rest = Math::rest($num->result, $denum->result);
return new Number($shots, $rest);
} else {
$shots = $num->result / $denum->result;
return new Number($shots);
}
}
开发者ID:athk,项目名称:XG-Proyect-v3.x.x,代码行数:14,代码来源:Math.php
示例15: toString
public function toString()
{
$html = "";
$width = Math::floor(100 / $this->iframes->length) - 1;
$_g = 0;
$_g1 = $this->iframes;
while ($_g < $_g1->length) {
$iframeUrl = $_g1[$_g];
++$_g;
$html .= "\n\t" . "<iframe src=\"" . _hx_string_or_null($iframeUrl) . "\" style=\"width:" . Std::string($width) . "%; height:100%; margin:0px; padding:0px; border:1px solid;\"></iframe>";
unset($iframeUrl);
}
return ltrim($html);
}
开发者ID:adrianmm44,项目名称:zcale,代码行数:14,代码来源:Iframes.class.php
示例16: index
public function index($value, $parameters = array())
{
if (!isset($parameters[0])) {
return 'Unknown';
}
if (!preg_match(Pattern::COORDINATES, $value, $point_1_matches)) {
return 'Unknown';
}
if (!preg_match(Pattern::COORDINATES, $parameters[0], $point_2_matches)) {
return 'Unknown';
}
$point_1 = array($point_1_matches[1], $point_1_matches[2]);
$point_2 = array($point_2_matches[1], $point_2_matches[2]);
return Math::getDistanceInKilometers($point_1, $point_2);
}
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:15,代码来源:mod.distance_in_km_from.php
示例17: do_hash
static function do_hash($s)
{
$b = 378551;
$a = 63689;
$hash = 0;
$i = 0;
$_g1 = 0;
$_g = strlen($s);
while ($_g1 < $_g) {
$i1 = $_g1++;
$hash = $hash * $a + _hx_char_code_at($s, $i1);
$a = $a * $b;
unset($i1);
}
return Math::abs($hash);
}
开发者ID:marcdraco,项目名称:Webrathea,代码行数:16,代码来源:Hashes.class.php
示例18: hex
static function hex($n, $digits = null)
{
$s = dechex($n);
$len = 8;
if (strlen($s) > StringTools_0($digits, $len, $n, $s)) {
$s = _hx_substr($s, -$len, null);
} else {
if ($digits !== null) {
if (strlen("0") === 0 || strlen($s) >= $digits) {
$s = $s;
} else {
$s = str_pad($s, Math::ceil(($digits - strlen($s)) / strlen("0")) * strlen("0") + strlen($s), "0", STR_PAD_LEFT);
}
}
}
return strtoupper($s);
}
开发者ID:marcdraco,项目名称:Webrathea,代码行数:17,代码来源:StringTools.class.php
示例19: sendVerifyLocalRequest
/**
* 本地验证
* @param type $ssid
* @param type $result
* @return type
*/
public static function sendVerifyLocalRequest($ssid, $result)
{
$mass = Context::getInstance()->get('yuc_mass', '');
$code = Crypt::decrypt(urldecode($mass), Math::erypt_key());
$code = str_replace(",", "", $code);
if ($code != '' && strtolower($code) === strtolower($result)) {
self::$_yuc_result = 1;
self::$_yuc_code = '';
self::$_yuc_details = '验证码输入正确';
} else {
self::$_yuc_result = 0;
self::$_yuc_code = 'E_LOCALVALID_001';
self::$_yuc_details = '验证码验证失败';
}
Log::Write('本地验证完成,输入结果为:' . $result . ';' . '', Log::DEBUG);
return array('code' => self::$_yuc_code, 'result' => self::$_yuc_result, 'details' => self::$_yuc_details);
}
开发者ID:saintho,项目名称:phpdisk,代码行数:23,代码来源:Valid.php
示例20: getquota
function getquota($who, $what)
{
global $conf;
if ($what == 'user') {
$quota = evoexec("-qu {$who}");
} elseif ($what == 'group') {
if ($conf['domaines']['driver'] == 'file') {
$quota = evoexec("-s");
} elseif ($conf['domaines']['driver'] == 'ldap') {
$quota = evoexec("-qg {$who}");
}
}
list($now, $limit) = split("/", $quota);
$now = $now / 1024;
$limit = $limit / 1024;
$quota = "<b>" . Math::arrondi($now) . "M</b>/" . Math::arrondi($limit) . "M";
return $quota;
}
开发者ID:Evolix,项目名称:evoadmin-mail,代码行数:18,代码来源:functions.php
注:本文中的Math类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论