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


PHP Math类代码示例

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


在下文中一共展示了Math类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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