• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bcscale函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convertDecimal2Binary

 /**
  * Convert decimal number as a string to binary number
  * For TblUtil in Karate rank
  *
  * Example:
  * Input:  string $uuid = "465827479475458048";
  * Output: string 10101001111100111001111111100000110000000001000000000000
  *
  * @time 2015/08/30 21:45
  *
  * @param $uuid string
  * @param $base string The convert base
  * @return bool
  */
 public static function convertDecimal2Binary($uuid = "", $base = "2")
 {
     if (empty($uuid) || bccomp($uuid, "0", 0) <= 0) {
         return false;
     }
     $binaryResult = "";
     bcscale(0);
     //Set the default precision
     $intBase = (int) $base;
     while (true) {
         if (substr_compare($uuid, "0", 0) == 0) {
             break;
         }
         $last = substr($uuid, -1);
         //Get the last number
         $divFlag = 0;
         if ($last % $intBase == 0) {
             //If $uuid could be divisible
             $binaryResult .= "0";
         } else {
             $binaryResult .= "1";
             $divFlag = 1;
         }
         if ($divFlag == 1) {
             $lastTwo = substr($uuid, -2);
             $replace = (string) ((int) $lastTwo - 1);
             $uuid = substr_replace($uuid, $replace, -2);
         }
         $uuid = bcdiv($uuid, $base);
     }
     $binaryResult = strrev($binaryResult);
     //Reversing the binary sequence to get the right result
     return $binaryResult;
 }
开发者ID:niceforbear,项目名称:lib,代码行数:48,代码来源:Toys.php


示例2: sortRentalPayment

 public function sortRentalPayment($data)
 {
     // Put into new array and order data by date, type
     $paymentData = array();
     foreach ($data as $key => $val) {
         // Add data to new array
         $paymentData["id_{$key}"] = $val;
         // Generate a sortable date field
         if ($val['date_due'] != 'N/A') {
             // Sort by date due
             $sortDate = $val['date_due'];
         } else {
             // Sort by date received
             $sortDate = $val['date_paid'];
         }
         $day = substr($sortDate, 0, 2);
         $month = substr($sortDate, 3, 2);
         $year = substr($sortDate, 6, 4);
         $paymentData["id_{$key}"]['sortableDate'] = mktime(0, 0, 0, $month, $day, $year);
     }
     uasort($paymentData, array('Datasource_Insurance_RentGuaranteeClaim_RentalPayment', '_actualSortRentalPayment'));
     // Add in arrears values to results array - now uses BC Math to prevent
     //   stuffs like '-0.00' from appearing.  True story.
     $accumulator = '0.00';
     bcscale(2);
     foreach ($paymentData as $key => $data) {
         $accumulator = bcadd($accumulator, bcsub($data['amount_due'], $data['amount_paid']));
         $paymentData[$key]['arrear_amount'] = $accumulator;
     }
     return $paymentData;
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:31,代码来源:RentalPayment.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: controller_mandelbrot

 function controller_mandelbrot($args)
 {
     bcscale(100);
     $options = $this->options($args);
     $level = any($args["level"], 8);
     $row = any($args["row"], 0);
     $column = any($args["column"], 0);
     $cache = $this->cacheinfo($level, $column, $row, $options);
     if (!file_exists($cache["path"])) {
         $maxlevel = $this->maxlevel($options["maxsize"]);
         $levelinfo = $this->levelinfo($maxlevel - $level, $options);
         $frame = $this->frame($row, $column, $levelinfo, $options);
         //$this->generate_mandelbrot($cache["path"], $levelinfo["tilesize"], $frame["min"], $frame["max"], $options["iterations"]);
         $this->generate_mandelbrot_c($cache["path"], $levelinfo["tilesize"], $options["framemin"], $options["framemax"], $options["iterations"], $level, $row, $column);
         /*
          print_pre($level);
          print_pre("Full size: " . $maxsize[0] . " x " . $maxsize[1]);
          print_pre("Scaled size: $lwidth x $lheight");
          print_pre("$numcolumns x $numrows");
          print_pre($scaledtilesize);
          
          print_pre($min);
          print_pre($max);
          return;
         */
     }
     header("Content-type: image/png");
     print file_get_contents($cache["path"]);
 }
开发者ID:ameyer430,项目名称:elation,代码行数:29,代码来源:deepzoom_mandelbrot.php


示例5: __construct

 /**
  * @param \DateTime $dateTime
  */
 public function __construct(\DateTime $dateTime = null)
 {
     bcscale(static::PRECISION_SCALE);
     if ($dateTime instanceof \DateTime) {
         $this->value = $this->dateTimeToJulianDay($dateTime);
     }
 }
开发者ID:mjaschen,项目名称:astrotools,代码行数:10,代码来源:JulianDay.php


示例6: expenseAccounts

 /**
  * @param Collection $accounts
  * @param Carbon     $start
  * @param Carbon     $end
  *
  * @return array
  */
 public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end)
 {
     $data = ['count' => 1, 'labels' => [], 'datasets' => [['label' => trans('firefly.spent'), 'data' => []]]];
     bcscale(2);
     $start->subDay();
     $ids = $this->getIdsFromCollection($accounts);
     $startBalances = Steam::balancesById($ids, $start);
     $endBalances = Steam::balancesById($ids, $end);
     $accounts->each(function (Account $account) use($startBalances, $endBalances) {
         $id = $account->id;
         $startBalance = $this->isInArray($startBalances, $id);
         $endBalance = $this->isInArray($endBalances, $id);
         $diff = bcsub($endBalance, $startBalance);
         $account->difference = round($diff, 2);
     });
     $accounts = $accounts->sortByDesc(function (Account $account) {
         return $account->difference;
     });
     foreach ($accounts as $account) {
         if ($account->difference > 0) {
             $data['labels'][] = $account->name;
             $data['datasets'][0]['data'][] = $account->difference;
         }
     }
     return $data;
 }
开发者ID:zetaron,项目名称:firefly-iii,代码行数:33,代码来源:ChartJsAccountChartGenerator.php


示例7: frontpage

 /**
  * @param Collection $paid
  * @param Collection $unpaid
  *
  * @return array
  */
 public function frontpage(Collection $paid, Collection $unpaid)
 {
     $paidDescriptions = [];
     $paidAmount = 0;
     $unpaidDescriptions = [];
     $unpaidAmount = 0;
     bcscale(2);
     /** @var TransactionJournal $entry */
     foreach ($paid as $entry) {
         // loop paid and create single entry:
         $paidDescriptions[] = $entry->description;
         $paidAmount = bcadd($paidAmount, $entry->amount_positive);
     }
     /** @var Bill $entry */
     foreach ($unpaid as $entry) {
         // loop unpaid:
         $description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
         $amount = bcdiv(bcadd($entry[0]->amount_max, $entry[0]->amount_min), 2);
         $unpaidDescriptions[] = $description;
         $unpaidAmount = bcadd($unpaidAmount, $amount);
         unset($amount, $description);
     }
     $data = [['value' => $unpaidAmount, 'color' => 'rgba(53, 124, 165,0.7)', 'highlight' => 'rgba(53, 124, 165,0.9)', 'label' => trans('firefly.unpaid')], ['value' => $paidAmount, 'color' => 'rgba(0, 141, 76, 0.7)', 'highlight' => 'rgba(0, 141, 76, 0.9)', 'label' => trans('firefly.paid')]];
     return $data;
 }
开发者ID:zetaron,项目名称:firefly-iii,代码行数:31,代码来源:ChartJsBillChartGenerator.php


示例8: scale

 public static function scale($scale)
 {
     if ($retval = bcscale($scale)) {
         static::$scale = $scale;
     }
     return $retval;
 }
开发者ID:danhunsaker,项目名称:bcmath,代码行数:7,代码来源:BC.php


示例9: pow

 /**
  * Exponential expression / raise number into power
  *
  * @param string $base         base to raise
  * @param string $exp          exponent to use
  * @param string $use_function pow function to use, or false for auto-detect
  *
  * @return mixed string or float
  */
 public static function pow($base, $exp, $use_function = '')
 {
     static $pow_function = null;
     if ($pow_function == null) {
         $pow_function = self::detectPow();
     }
     if (!$use_function) {
         if ($exp < 0) {
             $use_function = 'pow';
         } else {
             $use_function = $pow_function;
         }
     }
     if ($exp < 0 && $use_function != 'pow') {
         return false;
     }
     switch ($use_function) {
         case 'bcpow':
             // bcscale() needed for testing 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:altesien,项目名称:FinalProject,代码行数:44,代码来源:Util.class.php


示例10: __construct

 function __construct()
 {
     bcscale(0);
     $this->setEnv('test');
     $this->transDate = date('Ymd');
     $this->orderId = "00" . date('YmdHis');
 }
开发者ID:imvkmark,项目名称:l5-chinapay,代码行数:7,代码来源:Client.php


示例11: handle

 /**
  * Handle the event when journal is saved.
  *
  * @param  JournalCreated $event
  *
  * @return boolean
  */
 public function handle(JournalCreated $event)
 {
     /** @var TransactionJournal $journal */
     $journal = $event->journal;
     $piggyBankId = $event->piggyBankId;
     /** @var PiggyBank $piggyBank */
     $piggyBank = Auth::user()->piggybanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
     if (is_null($piggyBank)) {
         return false;
     }
     // update piggy bank rep for date of transaction journal.
     $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
     if (is_null($repetition)) {
         return false;
     }
     bcscale(2);
     $amount = $journal->amount_positive;
     // if piggy account matches source account, the amount is positive
     if ($piggyBank->account_id == $journal->source_account->id) {
         $amount = $amount * -1;
     }
     $repetition->currentamount = bcadd($repetition->currentamount, $amount);
     $repetition->save();
     PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date, 'amount' => $amount]);
     return true;
 }
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:33,代码来源:ConnectJournalToPiggyBank.php


示例12: execute

 public function execute($image)
 {
     bcscale(20);
     $curves = $this->argument(0)->value();
     $numPoints = count($curves);
     $img = $image->getCore();
     $gradient = new Imagick();
     $gradient->newImage(255, 1, new ImagickPixel('white'));
     $regression = new PolynomialRegression($numPoints);
     foreach ($curves as $point) {
         $regression->addData($point[0], $point[1]);
     }
     $coefficients = $regression->getCoefficients();
     for ($x = 0; $x < 255; ++$x) {
         $y = (int) max(0, min(255, $regression->interpolate($coefficients, $x)));
         $r = $g = $b = $y;
         $pixel = new ImagickPixel('rgb(' . $r . ',' . $g . ',' . $b . ')');
         $draw = new ImagickDraw();
         $draw->setFillColor($pixel);
         $draw->rectangle($x, 0, $x + 1, 1);
         $gradient->drawImage($draw);
     }
     $gradient->setImageInterpolateMethod(Imagick::INTERPOLATE_BILINEAR);
     $img->clutImage($gradient);
     return $image;
 }
开发者ID:bigfishtv,项目名称:intervention-image-commands,代码行数:26,代码来源:TankCurvesCommand.php


示例13: index

 /**
  * @param AccountRepositoryInterface $repository
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function index(AccountRepositoryInterface $repository)
 {
     $types = Config::get('firefly.accountTypesByIdentifier.asset');
     $count = $repository->countAccounts($types);
     bcscale(2);
     if ($count == 0) {
         return redirect(route('new-user.index'));
     }
     $title = 'Firefly';
     $subTitle = trans('firefly.welcomeBack');
     $mainTitleIcon = 'fa-fire';
     $transactions = [];
     $frontPage = Preferences::get('frontPageAccounts', []);
     $start = Session::get('start', Carbon::now()->startOfMonth());
     $end = Session::get('end', Carbon::now()->endOfMonth());
     $showTour = Preferences::get('tour', true)->data;
     $accounts = $repository->getFrontpageAccounts($frontPage);
     $savings = $repository->getSavingsAccounts();
     $piggyBankAccounts = $repository->getPiggyBankAccounts();
     $savingsTotal = 0;
     foreach ($savings as $savingAccount) {
         $savingsTotal = bcadd($savingsTotal, Steam::balance($savingAccount, $end));
     }
     $sum = $repository->sumOfEverything();
     if ($sum != 0) {
         Session::flash('error', 'Your transactions are unbalanced. This means a' . ' withdrawal, deposit or transfer was not stored properly. ' . 'Please check your accounts and transactions for errors.');
     }
     foreach ($accounts as $account) {
         $set = $repository->getFrontpageTransactions($account, $start, $end);
         if (count($set) > 0) {
             $transactions[] = [$set, $account];
         }
     }
     return view('index', compact('count', 'showTour', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
 }
开发者ID:leander091,项目名称:firefly-iii,代码行数:40,代码来源:HomeController.php


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


示例15: dopay

 public function dopay($payment)
 {
     $merId = $this->getConf('mer_id', __CLASS__);
     //客户号
     $mer_key = $this->getConf('mer_key', __CLASS__);
     //私钥
     bcscale(2);
     //组织给银联打过去要签名的数据 $args
     $args = array("version" => "1.0.0", "charset" => "UTF-8", "transType" => '01', "merAbbr" => $payment['shopName'], "merId" => $merId, "merCode" => "", "backEndUrl" => $this->notify_url, "frontEndUrl" => $this->callback_url, "acqCode" => "", "orderTime" => date('YmdHis', $payment['t_begin']), "orderNumber" => $payment['payment_id'], "commodityName" => "", "commodityUrl" => "", "commodityUnitPrice" => "", "commodityQuantity" => "", "transferFee" => "", "commodityDiscount" => "", "orderAmount" => bcadd($payment['cur_money'], 0) * 100, "orderCurrency" => 156, "customerName" => "", "defaultPayType" => "", "defaultBankNumber" => "", "transTimeout" => "", "customerIp" => $_SERVER['REMOTE_ADDR'], "origQid" => "", "merReserved" => "");
     //生成签名
     $chkvalue = $this->sign($args, 'MD5', $mer_key);
     //循环给表单赋值
     foreach ($args as $key => $val) {
         $this->add_field($key, $val);
     }
     //再往表单里面添加签名方法,签名
     $this->add_field('signMethod', 'MD5');
     $this->add_field('signature', $chkvalue);
     if ($this->is_fields_valiad()) {
         echo $this->get_html();
         exit;
     } else {
         return false;
     }
 }
开发者ID:noikiy,项目名称:Ecstore-to-odoo,代码行数:25,代码来源:unionpay.php


示例16: load_config

function load_config()
{
    $CI =& get_instance();
    foreach ($CI->Appconfig->get_all()->result() as $app_config) {
        $CI->config->set_item($CI->security->xss_clean($app_config->key), $CI->security->xss_clean($app_config->value));
    }
    //Set language from config database
    $language = $CI->config->item('language');
    //Loads all the language files from the language directory
    if (!empty($language)) {
        // fallback to English if language folder does not exist
        if (!file_exists('./application/language/' . $language)) {
            $language = 'en';
        }
        $CI->config->set_item('language', $language);
        $map = directory_map('./application/language/' . $language);
        foreach ($map as $file) {
            if (!is_array($file) && substr(strrchr($file, '.'), 1) == "php") {
                $CI->lang->load(strtr($file, '', '_lang.php'), $language);
            }
        }
    }
    //Set timezone from config database
    if ($CI->config->item('timezone')) {
        date_default_timezone_set($CI->config->item('timezone'));
    } else {
        date_default_timezone_set('America/New_York');
    }
    bcscale($CI->config->item('currency_decimals') + $CI->config->item('tax_decimals'));
}
开发者ID:gerarldlee,项目名称:opensourcepos,代码行数:30,代码来源:load_config.php


示例17: setDefaultScale

 /**
  * @param int $scale
  *
  * @throws \InvalidArgumentException
  */
 public static function setDefaultScale($scale)
 {
     if (!is_int($scale) || $scale < 0) {
         throw new \InvalidArgumentException('The scale must be a positive integer');
     }
     self::$defaultScale = $scale;
     \bcscale(self::$defaultScale);
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:13,代码来源:Decimal.php


示例18: restore

 /**
  * Restores the state of precision setting
  *
  */
 public static function restore()
 {
     if (self::$oldPrecision !== null && function_exists('ini_set')) {
         ini_set('precision', self::$oldPrecision[0]);
         ini_set('bcmath.scale', self::$oldPrecision[1]);
         bcscale(self::$oldPrecision[1]);
     }
     self::$setup = false;
 }
开发者ID:poef,项目名称:ariadne,代码行数:13,代码来源:Math.php


示例19: __construct

 function __construct()
 {
     bcscale(4);
     foreach (self::$variable as $key => $value) {
         $this->{$key} = 0;
     }
     $this->order = 0;
     $this->check = true;
 }
开发者ID:Kloadut,项目名称:noalyss_ynh,代码行数:9,代码来源:class_acc_compute.php


示例20: plug_pi

function plug_pi($p)
{
    bcscale(20);
    //nb after comma
    //$pi=msql_read('','public_pi','1',1); $pi=substr($pi,0,$p);
    //$math=bcdiv(bcadd(bcsqrt(5),1),2);//phi
    $pi4 = pi1($p ? $p : 40000);
    $ret = $pi4 * 4;
    return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:10,代码来源:pi.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bcsqrt函数代码示例发布时间:2022-05-24
下一篇:
PHP bcrypt函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap