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


PHP bcsub函数代码示例

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


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

示例1: oldTextual

function oldTextual($steamid)
{
    $result = 'Invalid input.';
    if (!preg_match('([a-zA-Z])', $steamid) && strlen($steamid) === 17) {
        // 64-bit int
        $acc_id = bcsub($steamid, '76561197960265728');
        $result = 'STEAM_0:';
        if ($acc_id % 2 === 0) {
            $result .= '0:';
        } else {
            $result .= '1:';
        }
        $result .= bcdiv($acc_id, '2', 0);
    }
    if (substr($steamid, 0, 2) === "[U") {
        // New textual format
        str_replace("[", "", str_replace("]", "", $steamid));
        $split = explode(':', $steamid);
        $result = 'STEAM_0:';
        $z = (int) $split[2];
        if ($z % 2 === 0) {
            $result .= '0:';
        } else {
            $result .= '1:';
        }
        $acc_id = bcdiv($z, '2', 0);
        $result .= $acc_id;
    }
    if (substr($steamid, 0, 6) === 'STEAM_') {
        $result = $steamid;
    }
    return $result;
}
开发者ID:SephirothSG,项目名称:MyBB-Plugins,代码行数:33,代码来源:PromoFunc.php

示例2: GetAuthID

function GetAuthID($i64friendID)
{
    $tmpfriendID = $i64friendID;
    $iServer = "1";
    if (extension_loaded('bcmath') == 1) {
        //decode communityid with bcmath
        if (bcmod($i64friendID, "2") == "0") {
            $iServer = "0";
        }
        $tmpfriendID = bcsub($tmpfriendID, $iServer);
        if (bccomp("76561197960265728", $tmpfriendID) == -1) {
            $tmpfriendID = bcsub($tmpfriendID, "76561197960265728");
        }
        $tmpfriendID = bcdiv($tmpfriendID, "2");
        return "STEAM_0:" . $iServer . ":" . $tmpfriendID;
    } else {
        if (extension_loaded('gmp') == 1) {
            //decode communityid with gmp
            if (gmp_mod($i64friendID, "2") == "0") {
                $iServer = "0";
            }
            $tmpfriendID = gmp_sub($tmpfriendID, $iServer);
            if (gmp_cmp("76561197960265728", $tmpfriendID) == -1) {
                $tmpfriendID = gmp_sub($tmpfriendID, "76561197960265728");
            }
            $tmpfriendID = gmp_div($tmpfriendID, "2");
            return "STEAM_0:" . $iServer . ":" . gmp_strval($tmpfriendID);
        }
    }
    return false;
}
开发者ID:GoeGaming,项目名称:bans.sevenelevenclan.org,代码行数:31,代码来源:steam.inc.php

示例3: G

function G($start = '', $end = '', $dec = 3)
{
    if (empty($_GET['need_stat'])) {
        //return false;
    }
    static $_info = array();
    if (is_float($end)) {
        $info[$start] = $end;
    } elseif (!empty($end)) {
        if (!isset($_info[$end])) {
            $_info[$end] = my_microtime_float($dec);
        }
        return number_format($_info[$end] - $_info[$start], $dec);
    } elseif (!empty($start)) {
        $_info[$start] = my_microtime_float($dec);
    } else {
        $temp = array();
        $findFirst = true;
        foreach ($_info as $key => $value) {
            if ($findFirst) {
                $baseTime = $value;
                $lastTime = 0;
                $findFirst = false;
            }
            $currTime = bcsub($value, $baseTime, 3);
            $currCostTime = bcsub($currTime, $lastTime, 3);
            $lastTime = $currTime;
            $temp[$key] = $currTime . ' [' . $currCostTime . ']';
        }
        return $temp;
    }
}
开发者ID:andychang88,项目名称:daddy-store.com,代码行数:32,代码来源:general.php

示例4: bcfact

function bcfact($fact, $scale = 100)
{
    if ($fact == 1) {
        return 1;
    }
    return bcmul($fact, bcfact(bcsub($fact, '1'), $scale), $scale);
}
开发者ID:Nilithus,项目名称:euler,代码行数:7,代码来源:euler024.php

示例5: handle

 /**
  * Handle the event.
  *
  * @param  JournalSaved $event
  *
  * @return void
  */
 public function handle(JournalSaved $event)
 {
     $journal = $event->journal;
     // get the event connected to this journal:
     /** @var PiggyBankEvent $event */
     $event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
     if (is_null($event)) {
         return;
     }
     $piggyBank = $event->piggyBank()->first();
     $repetition = null;
     if ($piggyBank) {
         /** @var PiggyBankRepetition $repetition */
         $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
     }
     if (is_null($repetition)) {
         return;
     }
     bcscale(2);
     $amount = $journal->amount;
     $diff = bcsub($amount, $event->amount);
     // update current repetition
     $repetition->currentamount = bcadd($repetition->currentamount, $diff);
     $repetition->save();
     $event->amount = $amount;
     $event->save();
 }
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:34,代码来源:UpdateJournalConnection.php

示例6: internal_to_numstr

function internal_to_numstr($num, $precision = -1, $round = true)
{
    if ($precision == -1) {
        $precision = 8;
        $tidy = true;
    } else {
        $tidy = false;
    }
    if (!is_string($num) && !is_resource($num)) {
        throw new Error('Coding error!', "internal_to_numstr argument has type '" . gettype($num) . "'");
    }
    $repr = gmp_strval($num);
    if ($round) {
        if ($repr > 0) {
            $repr = bcadd($repr, pow(10, 8 - $precision) / 2);
        } else {
            $repr = bcsub($repr, pow(10, 8 - $precision) / 2);
        }
    }
    $repr = bcdiv($repr, pow(10, 8), $precision);
    // now tidy output...
    if ($tidy) {
        return clean_sql_numstr($repr);
    }
    return sprintf("%.{$precision}f", $repr);
}
开发者ID:martinkirov,项目名称:intersango,代码行数:26,代码来源:db.php

示例7: frame

 function frame($row, $column, $levelinfo, $options)
 {
     $scaledtilesize = array(bcdiv(bcsub($options["framemax"][0], $options["framemin"][0]), $levelinfo["columns"]), bcdiv(bcsub($options["framemax"][1], $options["framemin"][1]), $levelinfo["rows"]));
     $ret["min"] = array(bcadd(bcmul($scaledtilesize[0], $column), $options["framemin"][0]), bcadd(bcmul($scaledtilesize[1], $row), $options["framemin"][1]));
     $ret["max"] = array(bcadd($ret["min"][0], $scaledtilesize[0]), bcadd($ret["min"][1], $scaledtilesize[1]));
     return $ret;
 }
开发者ID:ameyer430,项目名称:elation,代码行数:7,代码来源:deepzoom_mandelbrot.php

示例8: revalue

 function revalue($data, &$errors = array())
 {
     if (empty($data['transaction_date'])) {
         $data['transaction_date'] = date(DATE_FORMAT);
     }
     $glperiod = GLPeriod::getPeriod(fix_date($data['transaction_date']));
     if (!$glperiod || count($glperiod) == 0) {
         $errors[] = 'No period exists for this date';
         return false;
     }
     $data['value'] = bcsub($this->glbalance(), $data['new_balance']);
     $data['glperiods_id'] = $glperiod['id'];
     $data['source'] = 'C';
     $data['type'] = 'V';
     $data['glaccount_id'] = $this->currency_detail->writeoff_glaccount_id;
     $data['glcentre_id'] = $this->currency_detail->glcentre_id;
     GLTransaction::setTwinCurrency($data);
     $gl_trans[] = GLTransaction::Factory($data, $errors);
     $data['value'] = bcmul($data['value'], -1);
     $data['glaccount_id'] = $this->glaccount_id;
     $data['glcentre_id'] = $this->glcentre_id;
     GLTransaction::setTwinCurrency($data);
     $gl_trans[] = GLTransaction::Factory($data, $errors);
     $db = DB::Instance();
     $db->StartTrans();
     if (count($errors) == 0 && GLTransaction::saveTransactions($gl_trans, $errors)) {
         return $db->CompleteTrans();
     }
     $errors[] = 'Failed to save GL Transaction';
     $db->FailTrans();
     $db->CompleteTrans();
     return false;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:33,代码来源:CBAccount.php

示例9: checkGlobeadmin

function checkGlobeadmin($nuConfigDBHost, $nuConfigDBName, $nuConfigDBUser, $nuConfigDBPassword)
{
    $login = false;
    $session_id = $_REQUEST['sessid'];
    $db = new PDO("mysql:host={$nuConfigDBHost};dbname={$nuConfigDBName};charset=utf8", $nuConfigDBUser, $nuConfigDBPassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $values = array($session_id, 'globeadmin');
    $sql = "SELECT * FROM zzzsys_session WHERE zzzsys_session_id = ? AND sss_zzzsys_user_id = ?";
    $obj = $db->prepare($sql);
    $obj->execute($values);
    $recordObj = $obj->fetch(PDO::FETCH_OBJ);
    $result = $obj->rowCount();
    if ($result == 1) {
        $then = $recordObj->sss_timeout;
        $now = time();
        $diff = bcsub($now, $then, 0);
        if ($diff < 1800) {
            $login = true;
        }
    }
    if (!$login) {
        setError("Not Logged in as globeadmin");
    }
    unset($obj);
    unset($db);
    return $login;
}
开发者ID:natanoj,项目名称:nuBuilderPro,代码行数:27,代码来源:nuphpgit.php

示例10: 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

示例11: php_compat_bcpowmod

/**
 * Replace bcpowmod()
 *
 * @category    PHP
 * @package     PHP_Compat
 * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
 * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
 * @link        http://php.net/function.bcpowmod
 * @author      Sara Golemon <pollita@php.net>
 * @version     $Revision: 1.1 $
 * @since       PHP 5.0.0
 * @require     PHP 4.0.0 (user_error)
 */
function php_compat_bcpowmod($x, $y, $modulus, $scale = 0)
{
    // Sanity check
    if (!is_scalar($x)) {
        user_error('bcpowmod() expects parameter 1 to be string, ' . gettype($x) . ' given', E_USER_WARNING);
        return false;
    }
    if (!is_scalar($y)) {
        user_error('bcpowmod() expects parameter 2 to be string, ' . gettype($y) . ' given', E_USER_WARNING);
        return false;
    }
    if (!is_scalar($modulus)) {
        user_error('bcpowmod() expects parameter 3 to be string, ' . gettype($modulus) . ' given', E_USER_WARNING);
        return false;
    }
    if (!is_scalar($scale)) {
        user_error('bcpowmod() expects parameter 4 to be integer, ' . gettype($scale) . ' given', E_USER_WARNING);
        return false;
    }
    $t = '1';
    while (bccomp($y, '0')) {
        if (bccomp(bcmod($y, '2'), '0')) {
            $t = bcmod(bcmul($t, $x), $modulus);
            $y = bcsub($y, '1');
        }
        $x = bcmod(bcmul($x, $x), $modulus);
        $y = bcdiv($y, '2');
    }
    return $t;
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:43,代码来源:bcpowmod.php

示例12: getSteamID3

 public function getSteamID3()
 {
     $authserver = bcsub($this->steamID64, '76561197960265728') & 1;
     $authid = (bcsub($this->steamID64, '76561197960265728') - $authserver) / 2;
     $authid = 2 * intval($authid) + intval($authserver);
     return "U:1:{$authid}";
 }
开发者ID:kevingelion,项目名称:laravel-steam-auth,代码行数:7,代码来源:SteamInfo.php

示例13: bcinvert

 function bcinvert($a, $n)
 {
     // Sanity check
     if (!is_scalar($a)) {
         user_error('bcinvert() expects parameter 1 to be string, ' . gettype($a) . ' given', E_USER_WARNING);
         return false;
     }
     if (!is_scalar($n)) {
         user_error('bcinvert() expects parameter 2 to be string, ' . gettype($n) . ' given', E_USER_WARNING);
         return false;
     }
     $u1 = $v2 = '1';
     $u2 = $v1 = '0';
     $u3 = $n;
     $v3 = $a;
     while (bccomp($v3, '0')) {
         $q0 = bcdiv($u3, $v3);
         $t1 = bcsub($u1, bcmul($q0, $v1));
         $t2 = bcsub($u2, bcmul($q0, $v2));
         $t3 = bcsub($u3, bcmul($q0, $v3));
         $u1 = $v1;
         $u2 = $v2;
         $u3 = $v3;
         $v1 = $t1;
         $v2 = $t2;
         $v3 = $t3;
     }
     if (bccomp($u2, '0') < 0) {
         return bcadd($u2, $n);
     } else {
         return bcmod($u2, $n);
     }
 }
开发者ID:casan,项目名称:eccube-2_13,代码行数:33,代码来源:bcinvert.php

示例14: handle

 /**
  * Handle the event.
  *
  * @param  TransactionJournalUpdated $event
  * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
  *
  * @return bool
  */
 public function handle(TransactionJournalUpdated $event) : bool
 {
     $journal = $event->journal;
     if (!$journal->isTransfer()) {
         return true;
     }
     // get the event connected to this journal:
     /** @var PiggyBankEvent $event */
     $event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
     if (is_null($event)) {
         return false;
     }
     $piggyBank = $event->piggyBank()->first();
     $repetition = null;
     if (!is_null($piggyBank)) {
         /** @var PiggyBankRepetition $repetition */
         $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
     }
     if (is_null($repetition)) {
         return false;
     }
     $amount = TransactionJournal::amount($journal);
     $diff = bcsub($amount, $event->amount);
     // update current repetition
     $repetition->currentamount = bcadd($repetition->currentamount, $diff);
     $repetition->save();
     $event->amount = $amount;
     $event->save();
     return true;
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:38,代码来源:UpdateJournalConnection.php

示例15: get_profiling

 /**
  * Returns profiling information.
  */
 function get_profiling($group_name = 'default')
 {
     $i = 0;
     $total = 0;
     $result = array();
     $markers = $this->group_markers[$group_name];
     foreach ($markers as $marker => $index) {
         $time = $this->markers[$index];
         if ($i == 0) {
             $diff = 0;
         } else {
             $temp = $this->markers[$index - 1];
             if (extension_loaded('bcmath')) {
                 $diff = bcsub($time, $temp, 6);
                 $total = bcadd($total, $diff, 6);
             } else {
                 $diff = $time - $temp;
                 $total = $total + $diff;
             }
         }
         $result[$i]['name'] = $marker;
         $result[$i]['time'] = $time;
         $result[$i]['diff'] = $diff;
         $result[$i]['total'] = $total;
         $i++;
     }
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:31,代码来源:timer.class.php


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