com.caucho.quercus.lib
Class BcmathModule

java.lang.Object
  extended by com.caucho.quercus.module.AbstractQuercusModule
      extended by com.caucho.quercus.lib.BcmathModule
All Implemented Interfaces:
QuercusModule

public class BcmathModule
extends AbstractQuercusModule

PHP math routines.


Field Summary
static IniDefinition INI_BCMATH_SCALE
           
 
Fields inherited from class com.caucho.quercus.module.AbstractQuercusModule
PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER
 
Constructor Summary
BcmathModule()
           
 
Method Summary
static java.lang.String bcadd(Env env, Value value1, Value value2, int scale)
          Add two arbitrary precision numbers.
static int bccomp(Env env, Value value1, Value value2, int scale)
          Compare two arbitrary precision numbers, return -1 if value 1 < value2, 0 if value1 == value2, 1 if value1 > value2.
static java.lang.String bcdiv(Env env, Value value1, Value value2, int scale)
          Divide one arbitrary precision number (value1) by another (value2).
static java.lang.String bcmod(Env env, Value value, Value modulus)
          Return the modulus of an aribtrary precison number.
static java.lang.String bcmul(Env env, Value value1, Value value2, int scale)
          Multiply two arbitrary precision numbers.
static java.lang.String bcpow(Env env, Value base, Value exp, int scale)
          Raise one arbitrary precision number (base) to the power of another (exp).
static java.lang.String bcpowmod(Env env, java.math.BigDecimal base, java.math.BigDecimal exp, java.math.BigDecimal modulus, int scale)
          Raise one arbitrary precision number (base) to the power of another (exp), and then return the modulus.
static boolean bcscale(Env env, int scale)
          Set the default scale to use for subsequent calls to bcmath functions.
static java.lang.String bcsqrt(Env env, Value operand, int scale)
          Return the square root of an arbitrary precision number.
static java.lang.String bcsub(Env env, Value value1, Value value2, int scale)
          Subtract arbitrary precision number (value2) from another (value1).
 IniDefinitions getIniDefinitions()
          Returns the default php.ini values.
 java.lang.String[] getLoadedExtensions()
          Returns the extensions loaded by the module.
 
Methods inherited from class com.caucho.quercus.module.AbstractQuercusModule
addConstant, addConstant, addConstant, getConstMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INI_BCMATH_SCALE

public static final IniDefinition INI_BCMATH_SCALE
Constructor Detail

BcmathModule

public BcmathModule()
Method Detail

getLoadedExtensions

public java.lang.String[] getLoadedExtensions()
Description copied from class: AbstractQuercusModule
Returns the extensions loaded by the module.

Specified by:
getLoadedExtensions in interface QuercusModule
Overrides:
getLoadedExtensions in class AbstractQuercusModule

getIniDefinitions

public IniDefinitions getIniDefinitions()
Returns the default php.ini values.

Specified by:
getIniDefinitions in interface QuercusModule
Overrides:
getIniDefinitions in class AbstractQuercusModule

bcadd

public static java.lang.String bcadd(Env env,
                                     Value value1,
                                     Value value2,
                                     int scale)
Add two arbitrary precision numbers. The optional scale indicates the number of decimal digits to include in the result, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bccomp

public static int bccomp(Env env,
                         Value value1,
                         Value value2,
                         int scale)
Compare two arbitrary precision numbers, return -1 if value 1 < value2, 0 if value1 == value2, 1 if value1 > value2. The optional scale indicates the number of decimal digits to include in comparing the values, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bcdiv

public static java.lang.String bcdiv(Env env,
                                     Value value1,
                                     Value value2,
                                     int scale)
Divide one arbitrary precision number (value1) by another (value2). A division by zero results in a warning message and a return value of null. The optional scale indicates the number of decimal digits to include in the result, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bcmod

public static java.lang.String bcmod(Env env,
                                     Value value,
                                     Value modulus)
Return the modulus of an aribtrary precison number. The returned number is always a whole number. A modulus of 0 results in a division by zero warning message and a return value of null.


bcmul

public static java.lang.String bcmul(Env env,
                                     Value value1,
                                     Value value2,
                                     int scale)
Multiply two arbitrary precision numbers. The optional scale indicates the number of decimal digits to include in the result, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bcpow

public static java.lang.String bcpow(Env env,
                                     Value base,
                                     Value exp,
                                     int scale)
Raise one arbitrary precision number (base) to the power of another (exp). exp must be a whole number. Negative exp is supported. The optional scale indicates the number of decimal digits to include in the result, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bcpowmod

public static java.lang.String bcpowmod(Env env,
                                        java.math.BigDecimal base,
                                        java.math.BigDecimal exp,
                                        java.math.BigDecimal modulus,
                                        int scale)
Raise one arbitrary precision number (base) to the power of another (exp), and then return the modulus. The returned number is always a whole number. exp must be a whole number. Negative exp is supported. The optional scale indicates the number of decimal digits to include in the pow calculation, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bcscale

public static boolean bcscale(Env env,
                              int scale)
Set the default scale to use for subsequent calls to bcmath functions. The scale is the number of decimal points to include in the string that results from bcmath calculations. A default scale set with this function overrides the value of the "bcmath.scale" ini variable.


bcsqrt

public static java.lang.String bcsqrt(Env env,
                                      Value operand,
                                      int scale)
Return the square root of an arbitrary precision number. A negative operand results in a warning message and a return value of null. The optional scale indicates the number of decimal digits to include in the result, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".


bcsub

public static java.lang.String bcsub(Env env,
                                     Value value1,
                                     Value value2,
                                     int scale)
Subtract arbitrary precision number (value2) from another (value1). The optional scale indicates the number of decimal digits to include in the result, the default is the value of a previous call to bcscale(com.caucho.quercus.env.Env, int) or the value of the ini variable "bcmath.scale".