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


PHP gmp_mul函数代码示例

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


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

示例1: fact

function fact($x)
{
    if ($x <= 1) {
        return 1;
    }
    return gmp_mul($x, fact($x - 1));
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:002.php

示例2: GetFriendID

function GetFriendID($pszAuthID)
{
    $iServer = "0";
    $iAuthID = "0";
    $szAuthID = $pszAuthID;
    $szTmp = strtok($szAuthID, ":");
    while (($szTmp = strtok(":")) !== false) {
        $szTmp2 = strtok(":");
        if ($szTmp2 !== false) {
            $iServer = $szTmp;
            $iAuthID = $szTmp2;
        }
    }
    if ($iAuthID == "0") {
        return false;
    }
    if (extension_loaded('bcmath') == 1) {
        // calc communityid with bcmath
        $i64friendID = bcmul($iAuthID, "2");
        $i64friendID = bcadd($i64friendID, bcadd("76561197960265728", $iServer, 0), 0);
        return $i64friendID;
    } else {
        if (extension_loaded('gmp') == 1) {
            // calc communityid with gmp
            $i64friendID = gmp_mul($iAuthID, "2");
            $i64friendID = gmp_add($i64friendID, gmp_add("76561197960265728", $iServer));
            return gmp_strval($i64friendID);
        } else {
            $i64friendID = Mul(strval($iAuthID), "2");
            $i64friendID = Add(strval($i64friendID), Add("76561197960265728", strval($iServer)));
            return $i64friendID;
        }
    }
    return false;
}
开发者ID:GoeGaming,项目名称:bans.sevenelevenclan.org,代码行数:35,代码来源:steam.inc.php

示例3: setValue

 public function setValue(Content $content)
 {
     $binaryData = $content->binaryData;
     $offsetIndex = 0;
     $contentLength = $this->contentLength->length;
     $isNegative = (ord($binaryData[$offsetIndex]) & 0x80) != 0x0;
     $number = gmp_init(ord($binaryData[$offsetIndex++]) & 0x7f, 10);
     for ($i = 0; $i < $contentLength - 1; $i++) {
         $number = gmp_or(gmp_mul($number, 0x100), ord($binaryData[$offsetIndex++]));
     }
     if ($isNegative) {
         $number = gmp_sub($number, gmp_pow(2, 8 * $contentLength - 1));
     }
     $value = gmp_strval($number, 10);
     if (is_string($value)) {
         // remove gaps between hex digits
         $value = preg_replace('/\\s|0x/', '', $value);
     } elseif (is_numeric($value)) {
         $value = dechex($value);
     } else {
         throw new Exception('OctetString: unrecognized input type!');
     }
     if (strlen($value) % 2 != 0) {
         // transform values like 1F2 to 01F2
         $value = '0' . $value;
     }
     $this->value = $value;
 }
开发者ID:Adapik,项目名称:PHPASN1,代码行数:28,代码来源:Integer.php

示例4: get_funds_graph_data

function get_funds_graph_data()
{
    $btc = array();
    $fiat = array();
    $query = "\n        SELECT\n            req_type, amount, curr_type, " . sql_format_date('timest') . " AS timest2\n        FROM\n            requests\n        WHERE\n            status != 'CANCEL'\n        ORDER BY\n            timest;\n    ";
    $result = do_query($query);
    $btc_sum = 0;
    $fiat_sum = 0;
    while ($row = mysql_fetch_array($result)) {
        $req_type = $row['req_type'];
        $amount = $row['amount'];
        $curr_type = $row['curr_type'];
        $timest = $row['timest2'];
        if ($req_type == 'WITHDR') {
            $amount = gmp_mul(-1, $amount);
        }
        if ($curr_type == 'BTC') {
            $btc_sum = gmp_add($btc_sum, $amount);
            $btc[$timest] = internal_to_numstr($btc_sum);
        } else {
            $fiat_sum = gmp_add($fiat_sum, $amount);
            $fiat[$timest] = internal_to_numstr($fiat_sum);
        }
    }
    return array($btc, $fiat);
}
开发者ID:martinkirov,项目名称:intersango,代码行数:26,代码来源:graph.php

示例5: to64Bit

 /**
  * Convert 32-bit SteamID to 64-bit SteamID
  *
  * @param string|int $userId
  *
  * @return string
  * @throws Exception
  */
 public static function to64Bit($userId)
 {
     if (!function_exists('gmp_add')) {
         throw new Exception("GMP Library not installed. Cannot convert SteamIDs.");
     }
     return gmp_strval(gmp_add(gmp_mul(sprintf("%u", bindec(self::STEAM_ID_UPPER_BITS)), "4294967296"), sprintf("%u", $userId)));
 }
开发者ID:sjaakmoes,项目名称:dotapi2,代码行数:15,代码来源:UserId.php

示例6: assetNameToIDHex

 protected function assetNameToIDHex($asset_name)
 {
     if ($asset_name == 'BTC') {
         return '0';
     }
     if ($asset_name == 'XCP') {
         return '1';
     }
     if (substr($asset_name, 0, 1) == 'A') {
         // numerical asset
         // An integer between 26^12 + 1 and 256^8 (inclusive)
         $asset_id = gmp_init(substr($asset_name, 1));
         if ($asset_id < gmp_init(26) ** 12 + 1) {
             throw new Exception("Asset ID was too low", 1);
         }
         if ($asset_id > gmp_init(2) ** 64 - 1) {
             throw new Exception("Asset ID was too high", 1);
         }
         return gmp_strval($asset_id, 16);
     }
     $n = gmp_init(0);
     for ($i = 0; $i < strlen($asset_name); $i++) {
         $n = gmp_mul($n, 26);
         $char = ord(substr($asset_name, $i, 1));
         if ($char < 65 or $char > 90) {
             throw new Exception("Asset name invalid", 1);
         }
         $digit = $char - 65;
         $n = gmp_add($n, $digit);
     }
     return gmp_strval($n, 16);
 }
开发者ID:tokenly,项目名称:counterparty-transaction-composer,代码行数:32,代码来源:OpReturnBuilder.php

示例7: testMul

 public function testMul()
 {
     $this->assertEquals(gmp_strval(gmp_mul($this->a, $this->a)), $this->math->mul($this->a, $this->a));
     $this->assertEquals(gmp_strval(gmp_mul($this->b, $this->b)), $this->math->mul($this->b, $this->b));
     $this->assertEquals(gmp_strval(gmp_mul($this->c, $this->c)), $this->math->mul($this->c, $this->c));
     $this->assertEquals(1, $this->math->mul(1, 1));
 }
开发者ID:Invision70,项目名称:php-bitpay-client,代码行数:7,代码来源:GmpEngineTest.php

示例8: _bindecGmp

 /**
 * binary decode using gmp extension 
 */
 private static function _bindecGmp($bin)
 {
     $dec = gmp_init(0);
     for ($i = 0; $i < strlen($bin); $i++) {
         $dec = gmp_add(gmp_mul($dec, 256), ord($bin[$i]));
     }
     return $dec;
 }
开发者ID:uwitec,项目名称:outbuying,代码行数:11,代码来源:Dsa.php

示例9: bin2dec

 public function bin2dec($bin)
 {
     $dec = '0';
     for ($i = 0, $len = strlen($bin); $i < $len; $i++) {
         $dec = gmp_add(gmp_mul($dec, 2), $bin[$i]);
     }
     return $dec;
 }
开发者ID:kemoycampbell,项目名称:PHP-RSA,代码行数:8,代码来源:GMP.php

示例10: fact

function fact($x)
{
    $return = 1;
    for ($i = 2; $i <= $x; $i++) {
        $return = gmp_mul($return, $i);
    }
    return $return;
}
开发者ID:exakat,项目名称:exakat,代码行数:8,代码来源:Extgmp.01.php

示例11: makeId32

 private function makeId32($timestamp, $machine, $sequence)
 {
     $timestamp = gmp_mul((string) $timestamp, gmp_pow(2, 22));
     $machine = gmp_mul((string) $machine, gmp_pow(2, 12));
     $sequence = gmp_init((string) $sequence, 10);
     $value = gmp_or(gmp_or($timestamp, $machine), $sequence);
     return gmp_strval($value, 10);
 }
开发者ID:AlexanderGrom,项目名称:php-snowflake,代码行数:8,代码来源:snowflake.php

示例12: extractd

function extractd(&$n1, &$n2, $d, $y)
{
    global $u;
    $u = gmp_mul($d, gmp_mul(-10, $y));
    $n1 = gmp_mul($n1, 10);
    $n1 = gmp_add($n1, $u);
    $n2 = gmp_mul($n2, 10);
    $n2 = gmp_add($n2, $u);
}
开发者ID:neoedmund,项目名称:benchmarksgame,代码行数:9,代码来源:pidigits.php-3.php

示例13: generate

 public function generate($serial)
 {
     $mul = gmp_mul(strval($this->mulFactor), strval($serial));
     $add = gmp_add($mul, $this->diffFactor);
     $mod = gmp_mod($add, strval($this->amount));
     $num = gmp_strval($mod);
     //        $num = ($this->mulFactor * $serial + $this->diffFactor) % $this->amount;
     return str_pad($num, $this->length, $this->padding, STR_PAD_LEFT);
 }
开发者ID:qiuqiux,项目名称:serialno,代码行数:9,代码来源:PseudoRandom.php

示例14: getBits

 /**
  * @param $value
  *
  * @return string
  */
 public static function getBits($value)
 {
     $bits = [];
     for ($i = gmp_init(1); gmp_cmp($value, $i) >= 0; $i = gmp_mul($i, 2)) {
         if (static::has($value, $i)) {
             $bits[] = gmp_strval($i);
         }
     }
     return $bits;
 }
开发者ID:packaged,项目名称:helpers,代码行数:15,代码来源:BitWiseGmp.php

示例15: readNumber

function readNumber($fd, $len)
{
    $val = gmp_init(0);
    for ($inx = 0; $inx < $len; $inx++) {
        $data = fread($fd, 1);
        $val = gmp_mul($val, gmp_init(256));
        $val = gmp_add($val, gmp_init(ord($data[0])));
    }
    return $val;
}
开发者ID:patrickz98,项目名称:xavaro,代码行数:10,代码来源:EPGDatabaseDump.php


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