Methods summary
public
|
#
__construct( integer|string|float|NGS\BigDecimal $value = 0, integer $scale = null )
Create a new instance with decimal value and scale
Create a new instance with decimal value and scale
Parameters
- $value
integer|string|float|NGS\BigDecimal Decimal value or BigDecimal instance
- $scale
integer $scale Decimal scale (number of decimal places), uses scale from given
BigDecimal instance, or uses default scale if null
|
public static
array
|
#
toArray( array $items, boolean $allowNullValues = false )
Converts all elements in array to BigDecimal instance
Converts all elements in array to BigDecimal instance
Parameters
- $items
array $items Input array, each element must be a valid argument for BigDecimal
constructor
- $allowNullValues
boolean $allowNullValues Allow null values in input array
Returns
array Resulting BigDecimal array
Throws
|
public static
array
|
#
toArrayWithScale( array $items, integer $scale, boolean $allowNullValues = false )
Converts all elements in array to \NGS\BigDecimal instance
Converts all elements in array to \NGS\BigDecimal instance
Parameters
- $items
array $items Source array, each element must be a valid argument for BigDecimal
constructor
- $scale
integer $scale Set non-BigDecimal values to this scale or use default if null
- $allowNullValues
boolean $allowNullValues Allow elements with null value in array
Returns
array BigDecimal Resulting BigDecimal array
Throws
|
public static
|
#
round( mixed $number, mixed $scale = 0 )
|
protected
|
#
setScale( integer $scale )
Sets scale (number of decimal places)
Sets scale (number of decimal places)
Parameters
|
protected
|
#
setValue( string|integer|float $value )
Parameters
- $value
string|integer|float $value
|
public
string
|
#
getValue( )
Returns string representation of decimal value
Returns string representation of decimal value
Returns
string
|
public
integer
|
#
getScale( )
Returns decimal scale
Returns
integer
|
public
|
#
__get( mixed $name )
Magic getter for accessing private value and scale properties
Magic getter for accessing private value and scale properties
|
public
string
|
#
__toString( )
Returns string representation of decimal value
Returns string representation of decimal value
Returns
string
|
public
string
|
#
toStringWith( integer $scale )
Returns string representation of decimal value with given scale
Returns string representation of decimal value with given scale
Parameters
- $scale
integer $scale Desired scale (number of decimal places)
Returns
string
|
public
string
|
#
format( integer $scale )
Returns string representation of decimal value with given scale
Returns string representation of decimal value with given scale
Parameters
- $scale
integer $scale Desired scale (number of decimal places)
Returns
string
|
protected
|
|
public
NGS\BigDecimal
|
#
add( mixed $other )
Adds another BigDecimal value to this instance
Adds another BigDecimal value to this instance
Parameters
- $other
mixed $other BigDecimal Value to be added
Returns
|
protected
|
|
public
NGS\BigDecimal
|
#
sub( mixed $other )
Subtract another BigDecimal value from this instance
Subtract another BigDecimal value from this instance
Parameters
- $other
mixed $other BigDecimal Value to be subtracted
Returns
|
protected
|
|
public
integer
|
#
comp( mixed $other )
Compares with another BigDecimal
Compares with another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to compare with
Returns
integer Returns 0 if the two values are equal, 1 if other value is larger, -1 otherwise.
|
protected
|
|
public
boolean
|
#
gt( mixed $other )
Check if this value is greater than another BigDecimal
Check if this value is greater than another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to compare with
Returns
boolean Returns true if greater than other, false otherwise
|
protected
|
|
public
boolean
|
#
gte( mixed $other )
Check if this value is greater or equal than another BigDecimal
Check if this value is greater or equal than another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to compare with
Returns
boolean Returns true if greater or equal than other, false otherwise
|
protected
|
|
public
boolean
|
#
lt( mixed $other )
Check if this instance is less than another BigDecimal
Check if this instance is less than another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to compare with
Returns
boolean Returns true if less than other, false otherwise
|
protected
|
|
public
boolean
|
#
lte( mixed $other )
Check if this instance is less or equal than another BigDecimal
Check if this instance is less or equal than another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to compare with
Returns
boolean Returns true if less or equal than other, false otherwise
|
protected
|
|
public
NGS\BigDecimal
|
#
mul( mixed $other )
Multiply with another BigDecimal
Multiply with another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to multiply with
Returns
|
protected
|
|
public
NGS\BigDecimal
|
#
div( mixed $other )
Divide with another BigDecimal
Divide with another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to divide with
Returns
|
protected
|
|
public
NGS\BigDecimal
|
#
mod( mixed $other )
Get modulus with another BigDecimal
Get modulus with another BigDecimal
Parameters
- $other
mixed $other BigDecimal Value to multiply with
Returns
|
protected
|
|
public
NGS\BigDecimal
|
#
pow( mixed $other )
Raise this value to another BigDecimal value
Raise this value to another BigDecimal value
Parameters
- $other
mixed $other BigDecimal Value to multiply with
Returns
|
public
NGS\BigDecimal
|
|