Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: bcdiv - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

bcmod" width="11" height="7"/> <bccomp
Last updated: Mon, 05 Feb 2007

view this page in

bcdiv

(PHP 4, PHP 5)

bcdiv — 2つの任意精度数値で除算を行う

説明

string bcdiv ( string left_operand, string right_operand [, int scale] )

left_operandright_operand で除算します。

パラメータ

left_operand

左オペランドを表す文字列。

right_operand

右オペランドを表す文字列。

scale

このオプションパラメータを使用して、 結果の小数点以下の桁数を指定します。すべての関数で使用するデフォルトのスケールを定義するには bcscale() を使用します。

返り値

除算結果を文字列で返します。 right_operand が 0 の場合は NULL を返します。

例 313. bcdiv() の例

<?php

echo bcdiv('105', '6.55957', 3);  // 16.007

?>

参考

bcmul()



add a note add a note User Contributed Notes
bcdiv
cristianDOTzuddas]NOSPAM[gmailDOTcom
24-Jul-2005 09:10
Decimal to binary conversion, using BC Math.
Note: this function is VERY slow if the decimal number is too big!

<?
function bc_decbin($dec_str) {
   if (
strlen($dec_str)>0) {
      
$bin_str = '';
       do {
           if (((int)
$dec_str[strlen($dec_str)-1] % 2) === 0)
              
$bin_str .= '0';
           else
              
$bin_str .= '1';
          
          
$dec_str = bcdiv($dec_str, '2');
       } while (
$dec_str!='0');
      
       return
strrev($bin_str);
   }
   else
       return
null;
}
?>

-----
Cristian
www.CodeFlower.com

bcmod" width="11" height="7"/> <bccomp
Last updated: Mon, 05 Feb 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites