Re: bcmod()
| From: | Lars Torben Wilson | Date: | Tue, 17 Jun 2003 20:54:26 +0000 |
| Subject: | Re: bcmod() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151897@lists.php.net to get a copy of this message | ||
On Tue, 2003-06-17 at 11:42, Thomas Bolioli wrote:
> The docs (see below) for bcmod() are rather skimpy. Does anyone have a
> clue as to how it works. Basically I want to do this (below code). PS: I
> am new to PHP but not to programming in general.
> Tom
Unless you're using arbitrary-precision math, the overhead of using
bcmod() is probably not worth it. In general you would just use
the modulus operator '%':
http://www.php.net/manual/en/language.operators.arithmetic.php
bcmod(a, b) is the arbitrary-precision version of a % b;
At any rate, what is the code doing that you're not expecting?
Torben
> $i = 1;
> while (something true){
> $modulus = the_modulus_of($i / 4); // does php do % instead of /?
> if($modulus == 0){
> do_this_this_time();
> }
> $i++;
> }
>
> *bcmod*
>
> (PHP 3, PHP 4 )
> bcmod -- Get modulus of an arbitrary precision number
> Description
> string bcmod ( string left_operand, string modulus)
>
> Get the modulus of the left_operand using modulus.
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----