Page 1 of 1

alternative bcmul()

Posted: Mon May 23, 2005 12:27 am
by Ryu
Hi,

i need an alternative function which does the same as bcmul(). Please help me.

greetz

Ryu

Posted: Mon May 23, 2005 7:40 am
by Chris Corbyn
Why?

Code: Select all

function bcmul_alternative($n, $m, $dec=0) {
    $value = $n * $m;
    if ($dec) {
        $value = round($value, $dec);
    }
    return $value;
}

Posted: Mon May 23, 2005 8:06 am
by Ryu
and this function does exactly the same as bcmul() ? if so, thank you. you helped me.

Posted: Mon May 23, 2005 8:37 am
by Chris Corbyn
Well from what I read about bcmul() it just multiplies two floats and optionally rounds to X decimal places.

That's what the above does. The third paramter is optional but if given it will round to that many places. Unless I misunderstand what the function is for?

Posted: Mon May 23, 2005 9:08 am
by anjanesh
d11wtq wrote:Unless I misunderstand what the function is for?
Maybe BCMath isn't enabled on his server ?

Posted: Mon May 23, 2005 2:20 pm
by Syranide
If you want bcmul, you want bcmul, if he wouldn't need it he would just use the multiplicator sign (or did he missunderstand the meaning of bcmul?).

bcmul btw is used for arbitrary precision mathematics, meaning that you can do calculations with virtually any number, something you CAN'T do with $n * $m, as the precision for that is about 10 digits (roughly said) if I'm not mistkaken.

I don't know, perhaps "gmp_" can do this, but it's likelt not available.

Posted: Mon May 23, 2005 5:10 pm
by Chris Corbyn
Heh now I've been educated :oops:

Posted: Tue May 24, 2005 2:24 am
by Ryu
yes the problem is that bcmath is disabled at this server. but i don't have the permission to change this.