Locale/Math/PhpMath.php
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 [email protected] 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\LocaleUtility 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
Methods



Add(string $op1, string $op2, integer $scale = null) : string
staticBCAdd - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
$scale |
integer |
|
Returns



Comp(string $op1, string $op2, integer $scale = null) : string
staticBCComp - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
$scale |
integer |
|
Returns



Div(string $op1, string $op2, integer $scale = null) : string
staticBCDiv - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
$scale |
integer |
|
Returns



Mod(string $op1, string $op2) : string
staticBCMod - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
Returns



Mul(string $op1, string $op2, integer $scale = null) : string
staticBCMul - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
$scale |
integer |
|
Returns



Pow(string $op1, string $op2, integer $scale = null) : string
staticBCPow - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
$scale |
integer |
|
Returns



Sqrt(string $op1, integer $scale = null) : string
staticBCSqrt - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$scale |
integer |
|
Returns



Sub(string $op1, string $op2, integer $scale = null) : string
staticBCSub - fixes a problem of BCMath and exponential numbers
Parameters
Name |
Type |
Description |
$op1 |
string |
|
$op2 |
string |
|
$scale |
integer |
|
Returns



exponent(integer $value, integer $scale = null) : string
staticinheritedChanges exponential numbers to plain string numbers
Fixes a problem of BCMath with numbers containing exponents
Inherited from:
\Zend_Locale_Math::exponent()
Parameters
Name |
Type |
Description |
$value |
integer |
Value to erase the exponent |
$scale |
integer |
(Optional) Scale to use
|
Returns



floatalize(string $value) : void
staticinheritedConvert a scientific notation to float
Additionally fixed a problem with PHP <= 5.2.x with big integers
Inherited from:
\Zend_Locale_Math::floatalize()
Parameters
Name |
Type |
Description |
$value |
string |
|



localize(integer $value) : string
staticinheritedLocalizes an input from standard english notation
Fixes a problem of BCMath with setLocale which is PHP related
Inherited from:
\Zend_Locale_Math::localize()
Parameters
Name |
Type |
Description |
$value |
integer |
Value to normalize |
Returns
Type |
Description |
string |
Normalized string without BCMath problems |



normalize(integer $value) : string
staticinheritedNormalizes an input to standard english notation
Fixes a problem of BCMath with setLocale which is PHP related
Inherited from:
\Zend_Locale_Math::normalize()
Parameters
Name |
Type |
Description |
$value |
integer |
Value to normalize |
Returns
Type |
Description |
string |
Normalized string without BCMath problems |



round( $op1, $precision = 0) : void
staticinheritedSurprisingly, 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
Name |
Type |
Description |
$op1 |
|
|
$precision |
|
|