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.
category |
Zend |
package |
Zend_Locale |
copyright |
Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license |
New BSD License |
inherited_from |
\Zend_Locale_Math |
Methods
BCAdd - fixes a problem of BCMath and exponential numbers
Add(string $op1, string $op2, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Add() |
Parameters
$op1
$op2
$scale
BCAdd - fixes a problem of BCMath and exponential numbers
Add(string $op1, string $op2, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$op2
string
$scale
integer
Returns
string
BCComp - fixes a problem of BCMath and exponential numbers
Comp(string $op1, string $op2, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Comp() |
Parameters
$op1
$op2
$scale
BCComp - fixes a problem of BCMath and exponential numbers
Comp(string $op1, string $op2, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$op2
string
$scale
integer
Returns
string
BCDiv - fixes a problem of BCMath and exponential numbers
Div(string $op1, string $op2, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Div() |
Parameters
$op1
$op2
$scale
BCDiv - fixes a problem of BCMath and exponential numbers
Div(string $op1, string $op2, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$op2
string
$scale
integer
Returns
string
BCMod - fixes a problem of BCMath and exponential numbers
Mod(string $op1, string $op2)
Static
inherited_from |
\Zend_Locale_Math::Mod() |
Parameters
$op1
$op2
BCMod - fixes a problem of BCMath and exponential numbers
Mod(string $op1, string $op2) : string
InheritedStatic
Parameters
$op1
string
$op2
string
Returns
string
BCMul - fixes a problem of BCMath and exponential numbers
Mul(string $op1, string $op2, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Mul() |
Parameters
$op1
$op2
$scale
BCMul - fixes a problem of BCMath and exponential numbers
Mul(string $op1, string $op2, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$op2
string
$scale
integer
Returns
string
BCPow - fixes a problem of BCMath and exponential numbers
Pow(string $op1, string $op2, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Pow() |
Parameters
$op1
$op2
$scale
BCPow - fixes a problem of BCMath and exponential numbers
Pow(string $op1, string $op2, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$op2
string
$scale
integer
Returns
string
Scale()
Scale($scale)
Static
BCSqrt - fixes a problem of BCMath and exponential numbers
Sqrt(string $op1, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Sqrt() |
Parameters
$op1
$scale
BCSqrt - fixes a problem of BCMath and exponential numbers
Sqrt(string $op1, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$scale
integer
Returns
string
BCSub - fixes a problem of BCMath and exponential numbers
Sub(string $op1, string $op2, integer $scale = null
)
Static
inherited_from |
\Zend_Locale_Math::Sub() |
Parameters
$op1
$op2
$scale
BCSub - fixes a problem of BCMath and exponential numbers
Sub(string $op1, string $op2, integer $scale = null
) : string
InheritedStatic
Parameters
$op1
string
$op2
string
$scale
integer
Returns
string
disable()
disable()
Static
Changes exponential numbers to plain string numbers
Fixes a problem of BCMath with numbers containing exponents
exponent(integer $value, integer $scale = null
) : string
InheritedStatic
Parameters
$value
integer
Value to erase the exponent
$scale
integer
(Optional) Scale to use
Returns
string
Convert a scientific notation to float
Additionally fixed a problem with PHP <= 5.2.x with big integers
floatalize(string $value)
InheritedStatic
isBcmathDisabled()
isBcmathDisabled()
InheritedStatic
Localizes an input from standard english notation
Fixes a problem of BCMath with setLocale which is PHP related
localize(integer $value) : string
InheritedStatic
Parameters
$value
integer
Value to normalize
Returns
string
Normalized string without BCMath problems
Normalizes an input to standard english notation
Fixes a problem of BCMath with setLocale which is PHP related
normalize(integer $value) : string
InheritedStatic
Parameters
$value
integer
Value to normalize
Returns
string
Normalized string without BCMath problems
Surprisingly, the results of this implementation of round()
prove better than the native PHP 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);
round($op1, $precision = 0
)
InheritedStatic
Parameters
$op1
$precision
Properties
$_bcmathDisabled
$_bcmathDisabled
Static
$add
$add
Default
array('Zend_Locale_Math', 'Add')
Static
$comp
$comp
Default
array('Zend_Locale_Math', 'Comp')
Static
$defaultPrecision
$defaultPrecision
Static
$defaultScale
$defaultScale
Static
$div
$div
Default
array('Zend_Locale_Math', 'Div')
Static
$mod
$mod
Default
array('Zend_Locale_Math', 'Mod')
Static
$mul
$mul
Default
array('Zend_Locale_Math', 'Mul')
Static
$pow
$pow
Default
array('Zend_Locale_Math', 'Pow')
Static
$sqrt
$sqrt
Default
array('Zend_Locale_Math', 'Sqrt')
Static
$sub
$sub
Default
array('Zend_Locale_Math', 'Sub')
Static