API Documentation

Locale/Math.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 license@zend.com so we can send you a copy immediately.

category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Locale  
version
$Id: Math.php 23775 2011-03-01 17:25:24Z ralph $  

\Zend_Locale_Math

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. Thus, this file should be as light as possible.

category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Locale  

Properties

Propertypublic  $_bcmathDisabled= 'false'
static
Default valuefalseDetails
Type
Propertypublic  $add= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $comp= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $div= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $mod= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $mul= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $pow= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $scale= 'bcscale'
static
Default valuebcscaleDetails
Type
Propertypublic  $sqrt= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $sub= 'array'
static
Default valuearrayDetails
Type

Methods

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

BCAdd - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
$scale integer
Returns
Type Description
string
methodpublicComp( string $op1, string $op2, integer $scale = null ) : string
static

BCComp - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
$scale integer
Returns
Type Description
string
methodpublicDiv( string $op1, string $op2, integer $scale = null ) : string
static

BCDiv - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
$scale integer
Returns
Type Description
string
methodpublicMod( string $op1, string $op2 ) : string
static

BCMod - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
Returns
Type Description
string
methodpublicMul( string $op1, string $op2, integer $scale = null ) : string
static

BCMul - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
$scale integer
Returns
Type Description
string
methodpublicPow( string $op1, string $op2, integer $scale = null ) : string
static

BCPow - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
$scale integer
Returns
Type Description
string
methodpublicSqrt( string $op1, integer $scale = null ) : string
static

BCSqrt - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$scale integer
Returns
Type Description
string
methodpublicSub( string $op1, string $op2, integer $scale = null ) : string
static

BCSub - fixes a problem of BCMath and exponential numbers

Parameters
Name Type Description
$op1 string
$op2 string
$scale integer
Returns
Type Description
string
methodpublicexponent( integer $value, integer $scale = null ) : string
static

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

Parameters
Name Type Description
$value integer Value to erase the exponent
$scale integer

(Optional) Scale to use

Returns
Type Description
string
methodpublicfloatalize( string $value ) : void
static

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

Parameters
Name Type Description
$value string
methodpublicisBcmathDisabled( ) : void
static

methodpubliclocalize( integer $value ) : string
static

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

Parameters
Name Type Description
$value integer Value to normalize
Returns
Type Description
string Normalized string without BCMath problems
methodpublicnormalize( integer $value ) : string
static

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

Parameters
Name Type Description
$value integer Value to normalize
Returns
Type Description
string Normalized string without BCMath problems
methodpublicround(  $op1,  $precision = 0 ) : void
static

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);

Parameters
Name Type Description
$op1
$precision
Documentation was generated by DocBlox 0.13.3.