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


PHP pow函数代码示例

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


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

示例1: humanReadableBytes

 /**
  * Get human readable file size, quick and dirty.
  * 
  * @todo Improve i18n support.
  *
  * @param int $bytes
  * @param string $format
  * @param int|null $decimal_places
  * @return string Human readable string with file size.
  */
 public static function humanReadableBytes($bytes, $format = "en", $decimal_places = null)
 {
     switch ($format) {
         case "sv":
             $dec_separator = ",";
             $thousands_separator = " ";
             break;
         default:
         case "en":
             $dec_separator = ".";
             $thousands_separator = ",";
             break;
     }
     $b = (int) $bytes;
     $s = array('B', 'kB', 'MB', 'GB', 'TB');
     if ($b <= 0) {
         return "0 " . $s[0];
     }
     $con = 1024;
     $e = (int) log($b, $con);
     $e = min($e, count($s) - 1);
     $v = $b / pow($con, $e);
     if ($decimal_places === null) {
         $decimal_places = max(0, 2 - (int) log($v, 10));
     }
     return number_format($v, !$e ? 0 : $decimal_places, $dec_separator, $thousands_separator) . ' ' . $s[$e];
 }
开发者ID:varvanin,项目名称:currycms,代码行数:37,代码来源:Util.php

示例2: calculateGFRResult

 function calculateGFRResult()
 {
     $tmpArr = array();
     $tmpArr[] = date('Y-m-d H:i:s');
     //observation time
     $tmpArr[] = 'GFR (CALC)';
     //desc
     $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
     $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
     $genderFactor = null;
     $creaValue = null;
     $personAge = null;
     $raceFactor = 1;
     switch ($gender[key($gender)]) {
         case 'M':
             $genderFactor = 1;
             break;
         case 'F':
             $genderFactor = 0.742;
             break;
     }
     if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
         $creaValue = $crea[key($crea)]['value'];
     }
     $person = new Person();
     $person->personId = $this->_patientId;
     $person->populate();
     if ($person->age > 0) {
         $personAge = $person->age;
     }
     $personStat = new PatientStatistics();
     $personStat->personId = $this->_patientId;
     $personStat->populate();
     if ($personStat->race == "AFAM") {
         $raceFactor = 1.21;
     }
     $gfrValue = "INC";
     if ($personAge > 0 && $creaValue > 0) {
         $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
     }
     trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
     $tmpArr[] = $gfrValue;
     // lab value
     $tmpArr[] = 'mL/min/1.73 m2';
     //units
     $tmpArr[] = '';
     //ref range
     $tmpArr[] = '';
     //abnormal
     $tmpArr[] = 'F';
     //status
     $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
     // observationTime::(boolean)normal; 0 = abnormal, 1 = normal
     $tmpArr[] = '0';
     //sign
     //$this->_calcLabResults[uniqid()] = $tmpArr;
     $this->_calcLabResults[1] = $tmpArr;
     // temporarily set index to one(1) to be able to include in selected lab results
     return $tmpArr;
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:60,代码来源:CalcLabs.php

示例3: PMA_pow

/**
 * Exponential expression / raise number into power
 *
 * @param string $base         base to raise
 * @param string $exp          exponent to use
 * @param mixed  $use_function pow function to use, or false for auto-detect
 *
 * @return mixed string or float
 */
function PMA_pow($base, $exp, $use_function = false)
{
    static $pow_function = null;
    if (null == $pow_function) {
        $pow_function = PMA_detect_pow();
    }
    if (!$use_function) {
        $use_function = $pow_function;
    }
    if ($exp < 0 && 'pow' != $use_function) {
        return false;
    }
    switch ($use_function) {
        case 'bcpow':
            // bcscale() needed for testing PMA_pow() with base values < 1
            bcscale(10);
            $pow = bcpow($base, $exp);
            break;
        case 'gmp_pow':
            $pow = gmp_strval(gmp_pow($base, $exp));
            break;
        case 'pow':
            $base = (double) $base;
            $exp = (int) $exp;
            $pow = pow($base, $exp);
            break;
        default:
            $pow = $use_function($base, $exp);
    }
    return $pow;
}
开发者ID:AmberWish,项目名称:laba_web,代码行数:40,代码来源:common.lib.php

示例4: stdev

	function stdev(Array $x) {
		$n = count($x);
		if($n == 0 || ($n - 1) == 0) return null;
		$sum = sum($x);
		$sumSq = sum_sq($x);
		return sqrt(($sumSq - (pow($sum, 2)/$n))/($n - 1));
	}
开发者ID:revned,项目名称:orangephp,代码行数:7,代码来源:Helpers.php

示例5: main

function main($num)
{
    if ($num < 0) {
        $s = 1;
        $num = -$num;
    } else {
        $s = 0;
    }
    $zs = floor($num);
    $bzs = decbin($zs);
    $xs = $num - $zs;
    $res = (double) ($bzs . '.' . tenToBinary($xs, 1));
    $teme = ws($res);
    $e = decbin($teme + 127);
    if ($teme == 0) {
        $e = '0' . $e;
    }
    $temm = $res / pow(10, $teme);
    $m = end(explode(".", $temm));
    $lenm = strlen($m);
    if ($lenm < 23) {
        $m .= addzero(23 - $lenm);
    }
    return $s . ' ' . $e . ' ' . $m . ' ';
}
开发者ID:echosoar,项目名称:phpBinary,代码行数:25,代码来源:floatToIEEE32.php

示例6: postContent

 function postContent()
 {
     if (!($user = \Idno\Core\site()->session()->currentUser())) {
         $this->setResponse(403);
         echo 'You must be logged in to approve IndieAuth requests.';
         exit;
     }
     $me = $this->getInput('me');
     $client_id = $this->getInput('client_id');
     $redirect_uri = $this->getInput('redirect_uri');
     $state = $this->getInput('state');
     $scope = $this->getInput('scope');
     if (!empty($me) && parse_url($me, PHP_URL_HOST) == parse_url($user->getURL(), PHP_URL_HOST)) {
         $indieauth_codes = $user->indieauth_codes;
         if (empty($indieauth_codes)) {
             $indieauth_codes = array();
         }
         $code = md5(rand(0, 99999) . time() . $user->getUUID() . $client_id . $state . rand(0, 999999));
         $indieauth_codes[$code] = array('me' => $me, 'redirect_uri' => $redirect_uri, 'scope' => $scope, 'state' => $state, 'client_id' => $client_id, 'issued_at' => time(), 'nonce' => mt_rand(1000000, pow(2, 30)));
         $user->indieauth_codes = $indieauth_codes;
         $user->save();
         if (strpos($redirect_uri, '?') === false) {
             $redirect_uri .= '?';
         } else {
             $redirect_uri .= '&';
         }
         $redirect_uri .= http_build_query(array('code' => $code, 'state' => $state, 'me' => $me));
         $this->forward($redirect_uri);
     }
 }
开发者ID:pierreozoux,项目名称:Known,代码行数:30,代码来源:Approve.php

示例7: Correlation

function Correlation($array1, $array2)
{
    $avg_array1 = average($array1);
    $avg_array2 = average($array2);
    #print "$avg_array1----- $avg_array2<br>";
    $sum_correlation_up = 0;
    for ($i = 0; $i < count($array1); $i++) {
        $sum_correlation_up = $sum_correlation_up + ($array1[$i] - $avg_array1) * ($array2[$i] - $avg_array2);
    }
    #print $sum_correlation_up."<br>";
    $sum_array1_sumpow2 = 0;
    for ($i = 0; $i < count($array1); $i++) {
        $sum_array1_sumpow2 = $sum_array1_sumpow2 + pow($array1[$i] - $avg_array1, 2);
    }
    $sum_array1_sumpow2_sqrt = sqrt($sum_array1_sumpow2);
    #rint $sum_array1_sumpow2_sqrt."<br>";
    $sum_array2_sumpow2 = 0;
    for ($i = 0; $i < count($array1); $i++) {
        $sum_array2_sumpow2 = $sum_array2_sumpow2 + pow($array2[$i] - $avg_array2, 2);
    }
    $sum_array2_sumpow2_sqrt = sqrt($sum_array2_sumpow2);
    #print $sum_array2_sumpow2_sqrt."<br>";
    $correlation = $sum_correlation_up / ($sum_array1_sumpow2_sqrt * $sum_array2_sumpow2_sqrt);
    return $correlation;
}
开发者ID:jluzhhy,项目名称:Cross-microrna,代码行数:25,代码来源:NC_statistic.php

示例8: execute

 /**
  * {@inheritDoc}
  *
  * @param Convert $request
  */
 public function execute($request)
 {
     RequestNotSupportedException::assertSupports($this, $request);
     /** @var PaymentInterface $payment */
     $payment = $request->getSource();
     $model = ArrayObject::ensureArrayObject($payment->getDetails());
     //$model['DESCRIPTION'] = $payment->getDescription();
     if (false == $model['amount']) {
         $this->gateway->execute($currency = new GetCurrency($payment->getCurrencyCode()));
         if (2 < $currency->exp) {
             throw new RuntimeException('Unexpected currency exp.');
         }
         $divisor = pow(10, 2 - $currency->exp);
         $model['currency_code'] = $currency->numeric;
         $model['amount'] = abs($payment->getTotalAmount() / $divisor);
     }
     if (false == $model['order_id']) {
         $model['order_id'] = $payment->getNumber();
     }
     if (false == $model['customer_id']) {
         $model['customer_id'] = $payment->getClientId();
     }
     if (false == $model['customer_email']) {
         $model['customer_email'] = $payment->getClientEmail();
     }
     $request->setResult((array) $model);
 }
开发者ID:ekyna,项目名称:PayumSips,代码行数:32,代码来源:ConvertPaymentAction.php

示例9: fiat_and_btc_to_price

function fiat_and_btc_to_price($fiat, $btc, $round = 'round')
{
    $fiat = gmp_strval($fiat);
    $btc = gmp_strval($btc);
    if (gmp_cmp($btc, "0") == 0) {
        return "";
    } else {
        if ($round == 'round') {
            $price = bcdiv($fiat, $btc, PRICE_PRECISION + 1);
            return sprintf("%." . PRICE_PRECISION . "f", $price);
        } else {
            if ($round == 'down') {
                $price = bcdiv($fiat, $btc, PRICE_PRECISION);
                // echo "rounding $fiat / $btc = " . bcdiv($fiat, $btc, 8) . " down to $price<br/>\n";
                return $price;
            } else {
                if ($round == 'up') {
                    $raw = bcdiv($fiat, $btc, 8);
                    $adjust = bcsub(bcdiv(1, pow(10, PRICE_PRECISION), 8), '0.00000001', 8);
                    $price = bcadd($raw, $adjust, PRICE_PRECISION);
                    // echo "rounding $fiat / $btc = $raw up to $price<br/>\n";
                    return $price;
                } else {
                    throw new Error("Bad Argument", "fiat_and_btc_to_price() has round = '{$round}'");
                }
            }
        }
    }
}
开发者ID:martinkirov,项目名称:intersango,代码行数:29,代码来源:util.php

示例10: getGIFHeaderFilepointer

function getGIFHeaderFilepointer(&$fd, &$ThisFileInfo)
{
    $ThisFileInfo['fileformat'] = 'gif';
    $ThisFileInfo['video']['dataformat'] = 'gif';
    $ThisFileInfo['video']['lossless'] = true;
    fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
    $GIFheader = fread($fd, 13);
    $offset = 0;
    $ThisFileInfo['gif']['header']['raw']['identifier'] = substr($GIFheader, $offset, 3);
    $offset += 3;
    $ThisFileInfo['gif']['header']['raw']['version'] = substr($GIFheader, $offset, 3);
    $offset += 3;
    $ThisFileInfo['gif']['header']['raw']['width'] = LittleEndian2Int(substr($GIFheader, $offset, 2));
    $offset += 2;
    $ThisFileInfo['gif']['header']['raw']['height'] = LittleEndian2Int(substr($GIFheader, $offset, 2));
    $offset += 2;
    $ThisFileInfo['gif']['header']['raw']['flags'] = LittleEndian2Int(substr($GIFheader, $offset, 1));
    $offset += 1;
    $ThisFileInfo['gif']['header']['raw']['bg_color_index'] = LittleEndian2Int(substr($GIFheader, $offset, 1));
    $offset += 1;
    $ThisFileInfo['gif']['header']['raw']['aspect_ratio'] = LittleEndian2Int(substr($GIFheader, $offset, 1));
    $offset += 1;
    $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['gif']['header']['raw']['width'];
    $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['gif']['header']['raw']['height'];
    $ThisFileInfo['gif']['version'] = $ThisFileInfo['gif']['header']['raw']['version'];
    $ThisFileInfo['gif']['header']['flags']['global_color_table'] = (bool) ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x80);
    if ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x80) {
        // Number of bits per primary color available to the original image, minus 1
        $ThisFileInfo['gif']['header']['bits_per_pixel'] = 3 * ((($ThisFileInfo['gif']['header']['raw']['flags'] & 0x70) >> 4) + 1);
    } else {
        $ThisFileInfo['gif']['header']['bits_per_pixel'] = 0;
    }
    $ThisFileInfo['gif']['header']['flags']['global_color_sorted'] = (bool) ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x40);
    if ($ThisFileInfo['gif']['header']['flags']['global_color_table']) {
        // the number of bytes contained in the Global Color Table. To determine that
        // actual size of the color table, raise 2 to [the value of the field + 1]
        $ThisFileInfo['gif']['header']['global_color_size'] = pow(2, ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x7) + 1);
        $ThisFileInfo['video']['bits_per_sample'] = ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x7) + 1;
    } else {
        $ThisFileInfo['gif']['header']['global_color_size'] = 0;
    }
    if ($ThisFileInfo['gif']['header']['raw']['aspect_ratio'] != 0) {
        // Aspect Ratio = (Pixel Aspect Ratio + 15) / 64
        $ThisFileInfo['gif']['header']['aspect_ratio'] = ($ThisFileInfo['gif']['header']['raw']['aspect_ratio'] + 15) / 64;
    }
    if ($ThisFileInfo['gif']['header']['flags']['global_color_table']) {
        $GIFcolorTable = fread($fd, 3 * $ThisFileInfo['gif']['header']['global_color_size']);
        $offset = 0;
        for ($i = 0; $i < $ThisFileInfo['gif']['header']['global_color_size']; $i++) {
            //$ThisFileInfo['gif']['global_color_table']['red'][$i]   = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
            //$ThisFileInfo['gif']['global_color_table']['green'][$i] = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
            //$ThisFileInfo['gif']['global_color_table']['blue'][$i]  = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
            $red = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
            $green = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
            $blue = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
            $ThisFileInfo['gif']['global_color_table'][$i] = $red << 16 | $green << 8 | $blue;
        }
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:sotf,代码行数:60,代码来源:getid3.gif.php

示例11: round_up

    function round_up($value, $places)
 {
 	$mult = pow(10, abs($places));
 	return $places < 0 ?
 	ceil($value / $mult) * $mult :
 	ceil($value * $mult) / $mult;
 }
开发者ID:sarankh80,项目名称:lnms,代码行数:7,代码来源:DbLoanILtest.php

示例12: hexTo32Float

function hexTo32Float($strHex)
{
    $v = hexdec($strHex);
    $x = ($v & (1 << 23) - 1) + (1 << 23) * ($v >> 31 | 1);
    $exp = ($v >> 23 & 0xff) - 127;
    return $x * pow(2, $exp - 23);
}
开发者ID:RawLiquid,项目名称:Data_Logger,代码行数:7,代码来源:test.php

示例13: display

 function display()
 {
     global $mod_strings, $export_module, $current_language, $theme, $current_user, $dashletData, $sugar_flavor;
     if ($this->checkPostMaxSizeError()) {
         $this->errors[] = $GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT'];
         $contentLength = $_SERVER['CONTENT_LENGTH'];
         $maxPostSize = ini_get('post_max_size');
         if (stripos($maxPostSize, "k")) {
             $maxPostSize = (int) $maxPostSize * pow(2, 10);
         } elseif (stripos($maxPostSize, "m")) {
             $maxPostSize = (int) $maxPostSize * pow(2, 20);
         }
         $maxUploadSize = ini_get('upload_max_filesize');
         if (stripos($maxUploadSize, "k")) {
             $maxUploadSize = (int) $maxUploadSize * pow(2, 10);
         } elseif (stripos($maxUploadSize, "m")) {
             $maxUploadSize = (int) $maxUploadSize * pow(2, 20);
         }
         $max_size = min($maxPostSize, $maxUploadSize);
         $errMessage = string_format($GLOBALS['app_strings']['UPLOAD_MAXIMUM_EXCEEDED'], array($contentLength, $max_size));
         $this->errors[] = '* ' . $errMessage;
         $this->displayErrors();
     }
     include 'modules/Home/index.php';
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:25,代码来源:view.list.php

示例14: testByteBoundaryDecimalVarint

 /**
  * Ensure Decimal/Varint encoding on byte boundaries
  *
  * This test will ensure that the PHP driver is properly encoding Decimal
  * and Varint datatypes for positive values with leading 1's that land on
  * a byte boundary.
  *
  * @test
  * @ticket PHP-70
  */
 public function testByteBoundaryDecimalVarint()
 {
     // Create the table
     $query = "CREATE TABLE {$this->tableNamePrefix} (key timeuuid PRIMARY KEY, value_decimal decimal, value_varint varint)";
     $this->session->execute(new SimpleStatement($query));
     // Iterate through a few byte boundary positive values
     foreach (range(1, 20) as $i) {
         // Assign the values for the statement
         $key = new Timeuuid();
         $value_varint = pow(2, 8 * $i) - 1;
         $value_decimal = $value_varint / 100;
         $values = array($key, new Decimal($value_decimal), new Varint($value_varint));
         // Insert the value into the table
         $query = "INSERT INTO {$this->tableNamePrefix} (key, value_decimal, value_varint) VALUES (?, ?, ?)";
         $statement = new SimpleStatement($query);
         $options = new ExecutionOptions(array("arguments" => $values));
         $this->session->execute($statement, $options);
         // Select the decimal and varint
         $query = "SELECT value_decimal, value_varint FROM {$this->tableNamePrefix} WHERE key=?";
         $statement = new SimpleStatement($query);
         $options = new ExecutionOptions(array("arguments" => array($key)));
         $rows = $this->session->execute($statement, $options);
         // Ensure the decimal and varint are valid
         $this->assertCount(1, $rows);
         $row = $rows->first();
         $this->assertNotNull($row);
         $this->assertArrayHasKey("value_decimal", $row);
         $this->assertEquals($values[1], $row["value_decimal"]);
         $this->assertArrayHasKey("value_varint", $row);
         $this->assertEquals($values[2], $row["value_varint"]);
     }
 }
开发者ID:harley84,项目名称:php-driver,代码行数:42,代码来源:DatatypeIntegrationTest.php

示例15: fileSize

 /**
  * Format a filesize
  *
  * @param int $size In bytes
  * @return string
  */
 public function fileSize($size)
 {
     if (!$size) {
         return '0 ' . $this->_sizes[0];
     }
     return round($size / pow(1024, $i = floor(log($size, 1024))), $i > 1 ? 2 : 0) . ' ' . $this->_sizes[$i];
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:13,代码来源:FileSize.php


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