Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


php-bcmath requires

 
Post new topic   Reply to topic    Cacti Forum Index -> Help: Unstable Development Versions
Author Message
Linegod
Developer


Joined: 20 Feb 2003
Posts: 518
Location: Canada

PostPosted: Thu Mar 31, 2005 8:59 am    Post subject: php-bcmath requires Reply with quote

It would appear that the CVS version requires php-bcmath.

This is not a very common extension for at least RPM based distros.
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9723
Location: MI, USA

PostPosted: Thu Mar 31, 2005 1:33 pm    Post subject: Reply with quote

It was implemented due to the fact that it supports the modulus function. If you know of any equivalent builtin function, please advise.

TheWitness
Back to top
Linegod
Developer


Joined: 20 Feb 2003
Posts: 518
Location: Canada

PostPosted: Thu Mar 31, 2005 2:23 pm    Post subject: Reply with quote

Not built in, but provide on the the bcmod page at php.net:

Code:

<?php
 /**
  * my_bcmod - get modulus (substitute for bcmod)
  * string my_bcmod ( string left_operand, int modulus )
  * left_operand can be really big, but be carefull with modulus :(
  * by Andrius Baranauskas and Laurynas Butkus :) Vilnius, Lithuania
  **/
 function my_bcmod( $x, $y )
 {
    // how many numbers to take at once? carefull not to exceed (int)
    $take = 5;   
    $mod = '';
 
    do
    {
        $a = (int)$mod.substr( $x, 0, $take );
        $x = substr( $x, $take );
        $mod = $a % $y;   
    }
    while ( strlen($x) );
 
    return (int)$mod;
 }
 
 // example
 echo my_bcmod( "7044060001970316212900", 150 );
 ?>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Help: Unstable Development Versions All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group