Bcmath extension adapter

package Default

 Methods

Constructor Sets Bcmath scale factor to zero

__construct() 

Get absolute value of a big integer

abs(string $operand) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::abs()

Parameters

$operand

string

Returns

string

Add two big integers

add(string $leftOperand, string $rightOperand) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::add()

Parameters

$leftOperand

string

$rightOperand

string

Returns

string

Base conversion. Bases 2.

baseConvert(string $operand, integer $fromBase, integer $toBase = 10) : string

.62 are supported

inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::baseConvert()

Parameters

$operand

string

$fromBase

integer

$toBase

integer

Exceptions

\Zend\Math\BigInteger\Exception\InvalidArgumentException

Returns

string

Convert big integer into it's binary number representation

binToInt(string $bytes, boolean $twoc = false) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::binToInt()

Parameters

$bytes

string

$twoc

boolean

whether binary number is in twos' complement form

Returns

string

Compare two big integers and returns result as an integer where Returns < 0 if leftOperand is less than rightOperand; > 0 if leftOperand is greater than rightOperand, and 0 if they are equal.

comp(string $leftOperand, string $rightOperand) : integer
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::comp()

Parameters

$leftOperand

string

$rightOperand

string

Returns

integer

Divide two big integers and return integer part result.

div(string $leftOperand, string $rightOperand) : string

Raises exception if the divisor is zero.

inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::div()

Parameters

$leftOperand

string

$rightOperand

string

Exceptions

\Zend\Math\BigInteger\Exception\DivisionByZeroException

Returns

string

Create string representing big integer in decimal form from arbitrary integer format

init(string $operand, integer|null $base = null) : boolean | string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::init()

Parameters

$operand

string

$base

integernull

Returns

booleanstring

Convert big integer into it's binary number representation

intToBin(string $operand, boolean $twoc = false) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::intToBin()

Parameters

$operand

string

$twoc

boolean

return in two's complement form

Returns

string

Get modulus of a big integer

mod(string $leftOperand, string $rightOperand) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::mod()

Parameters

$leftOperand

string

$rightOperand

string

Returns

string

Multiply two big integers

mul(string $leftOperand, string $rightOperand) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::mul()

Parameters

$leftOperand

string

$rightOperand

string

Returns

string

Raise a big integers to another

pow(string $operand, string $exp) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::pow()

Parameters

$operand

string

$exp

string

Returns

string

Raise a big integer to another, reduced by a specified modulus

powmod(string $leftOperand, string $rightOperand, string $modulus) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::powmod()

Parameters

$leftOperand

string

$rightOperand

string

$modulus

string

Returns

string

Get the square root of a big integer

sqrt(string $operand) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::sqrt()

Parameters

$operand

string

Returns

string

Subtract two big integers

sub(string $leftOperand, string $rightOperand) : string
inherited_from \Zend\Math\BigInteger\Adapter\AdapterInterface::sub()

Parameters

$leftOperand

string

$rightOperand

string

Returns

string