Locale/Math/PhpMath.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Locale  
Version
$Id: PhpMath.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Locale_Math_PhpMath

Package: Zend\Locale
Utility class for proxying math function to bcmath functions, if present, otherwise to PHP builtin math operators, with limited detection of overflow conditions.

Sampling of PHP environments and platforms suggests that at least 80% to 90% support bcmath. This file should only be loaded for the 10% to 20% lacking access to the bcmath extension.

Parent(s)
\Zend_Locale_Math
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertypublic$_bcmathDisabled = false
staticinheritedInherited from: \Zend_Locale_Math::$$_bcmathDisabled
Default valuefalseDetails
Type
n/a
Inherited_from
\Zend_Locale_Math::$$_bcmathDisabled  
>VPropertypublic$add = array('Zend_Locale_Math', 'Add')
staticinheritedInherited from: \Zend_Locale_Math::$$add
Default valuearray('Zend_Locale_Math', 'Add')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$add  
>VPropertypublic$comp = array('Zend_Locale_Math', 'Comp')
staticinheritedInherited from: \Zend_Locale_Math::$$comp
Default valuearray('Zend_Locale_Math', 'Comp')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$comp  
>VPropertypublic$defaultPrecision
static
Details
Type
n/a
>VPropertypublic$defaultScale
static
Details
Type
n/a
>VPropertypublic$div = array('Zend_Locale_Math', 'Div')
staticinheritedInherited from: \Zend_Locale_Math::$$div
Default valuearray('Zend_Locale_Math', 'Div')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$div  
>VPropertypublic$mod = array('Zend_Locale_Math', 'Mod')
staticinheritedInherited from: \Zend_Locale_Math::$$mod
Default valuearray('Zend_Locale_Math', 'Mod')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$mod  
>VPropertypublic$mul = array('Zend_Locale_Math', 'Mul')
staticinheritedInherited from: \Zend_Locale_Math::$$mul
Default valuearray('Zend_Locale_Math', 'Mul')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$mul  
>VPropertypublic$pow = array('Zend_Locale_Math', 'Pow')
staticinheritedInherited from: \Zend_Locale_Math::$$pow
Default valuearray('Zend_Locale_Math', 'Pow')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$pow  
>VPropertypublic$scale = 'bcscale'
staticinheritedInherited from: \Zend_Locale_Math::$$scale
Default value'bcscale'Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$scale  
>VPropertypublic$sqrt = array('Zend_Locale_Math', 'Sqrt')
staticinheritedInherited from: \Zend_Locale_Math::$$sqrt
Default valuearray('Zend_Locale_Math', 'Sqrt')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$sqrt  
>VPropertypublic$sub = array('Zend_Locale_Math', 'Sub')
staticinheritedInherited from: \Zend_Locale_Math::$$sub
Default valuearray('Zend_Locale_Math', 'Sub')Details
Type
n/a
Inherited_from
\Zend_Locale_Math::$$sub  

Methods

methodpublicAdd(string $op1, string $op2, integer $scale = null) : string
static

BCAdd - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
$scaleinteger
Returns
TypeDescription
string
methodpublicComp(string $op1, string $op2, integer $scale = null) : string
static

BCComp - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
$scaleinteger
Returns
TypeDescription
string
methodpublicDiv(string $op1, string $op2, integer $scale = null) : string
static

BCDiv - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
$scaleinteger
Returns
TypeDescription
string
methodpublicMod(string $op1, string $op2) : string
static

BCMod - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
Returns
TypeDescription
string
methodpublicMul(string $op1, string $op2, integer $scale = null) : string
static

BCMul - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
$scaleinteger
Returns
TypeDescription
string
methodpublicPow(string $op1, string $op2, integer $scale = null) : string
static

BCPow - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
$scaleinteger
Returns
TypeDescription
string
methodpublicScale( $scale) : void
static

Parameters
NameTypeDescription
$scale
methodpublicSqrt(string $op1, integer $scale = null) : string
static

BCSqrt - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$scaleinteger
Returns
TypeDescription
string
methodpublicSub(string $op1, string $op2, integer $scale = null) : string
static

BCSub - fixes a problem of BCMath and exponential numbers

Parameters
NameTypeDescription
$op1string
$op2string
$scaleinteger
Returns
TypeDescription
string
methodpublicdisable() : void
static

methodpublicexponent(integer $value, integer $scale = null) : string
staticinherited

Changes exponential numbers to plain string numbers Fixes a problem of BCMath with numbers containing exponents

Inherited from: \Zend_Locale_Math::exponent()
Parameters
NameTypeDescription
$valueinteger

Value to erase the exponent

$scaleinteger

(Optional) Scale to use

Returns
TypeDescription
string
methodpublicfloatalize(string $value) : void
staticinherited

Convert a scientific notation to float Additionally fixed a problem with PHP <= 5.2.x with big integers

Inherited from: \Zend_Locale_Math::floatalize()
Parameters
NameTypeDescription
$valuestring
methodpublicisBcmathDisabled() : void
staticinherited

Inherited from: \Zend_Locale_Math::isBcmathDisabled()
methodpubliclocalize(integer $value) : string
staticinherited

Localizes an input from standard english notation Fixes a problem of BCMath with setLocale which is PHP related

Inherited from: \Zend_Locale_Math::localize()
Parameters
NameTypeDescription
$valueinteger

Value to normalize

Returns
TypeDescription
stringNormalized string without BCMath problems
methodpublicnormalize(integer $value) : string
staticinherited

Normalizes an input to standard english notation Fixes a problem of BCMath with setLocale which is PHP related

Inherited from: \Zend_Locale_Math::normalize()
Parameters
NameTypeDescription
$valueinteger

Value to normalize

Returns
TypeDescription
stringNormalized string without BCMath problems
methodpublicround( $op1,  $precision = 0) : void
staticinherited

Surprisingly, the results of this implementation of round() prove better than the native PHP round().

Inherited from: \Zend_Locale_Math::round()

For example, try: round(639.795, 2); round(267.835, 2); round(0.302515, 5); round(0.36665, 4); then try: Zend_Locale_Math::round('639.795', 2);

Parameters
NameTypeDescription
$op1
$precision
Documentation was generated by phpDocumentor 2.0.0a12.