PHP: bcdiv - Manual

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

search for in the

bcmod bccomp

Last updated: Sat, 27 Jan 2007

view this page in

# bcdiv

(PHP 3, PHP 4, PHP 5)

bcdiv -- Divide two arbitrary precision numbers

## Description

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

Divides the `left_operand` by the `right_operand` and returns the result. The optional `scale` sets the number of digits after the decimal place in the result, which defaults to 0.

## Примеры

Пример 1. bcdiv() example

`<?php echo bcdiv('105', '6.55957', 3); // 16.007 ?>`

## Смотрите также

bcmul().

add a note User Contributed Notes
bcdiv
cristianDOTzuddas]NOSPAM[gmailDOTcom
24-Jul-2005 05: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`
add a note
bcmod bccomp

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST