BigDecimal

Immutable, arbitrary-precision signed decimal numbers.
extends Brick\Math\BigNumber
Methods Summary
protected
# __construct( string $value , int $scale = 0 )
Protected constructor. Use a factory method to obtain an instance.
public static
# of( \BigNumber|\number|string $value )
Creates a BigDecimal of the given value.

Overrides

public static
# ofUnscaledValue( \BigNumber|\number|string $value , int $scale = 0 )
Creates a BigDecimal from an unscaled value and a scale. Example: `(12345, 3)` will result in the BigDecimal `12.345`.
public static
# zero( )
Returns a BigDecimal representing zero, with a scale of zero.
public static
# one( )
Returns a BigDecimal representing one, with a scale of zero.
public static
# ten( )
Returns a BigDecimal representing ten, with a scale of zero.
public
# plus( \BigNumber|\number|string $that )
Returns the sum of this number and the given one. The result has a scale of `max($this->scale, $that->scale)`.
public
# minus( \BigNumber|\number|string $that )
Returns the difference of this number and the given one. The result has a scale of `max($this->scale, $that->scale)`.
public
# multipliedBy( \BigNumber|\number|string $that )
Returns the product of this number and the given one. The result has a scale of `$this->scale + $that->scale`.
public
# dividedBy( \BigNumber|\number|string $that , int $scale = NULL, int $roundingMode = 0 )
Returns the result of the division of this number by the given one, at the given scale.
public
# exactlyDividedBy( \BigNumber|\number|string $that )
Returns the exact result of the division of this number by the given one. The scale of the result is automatically calculated to fit all the fraction digits.
public
# power( int $exponent )
Returns this number exponentiated to the given value. The result has a scale of `$this->scale * $exponent`.
public
# quotient( \BigNumber|\number|string $that )
Returns the quotient of the division of this number by this given one. The quotient has a scale of `0`.
public
# remainder( \BigNumber|\number|string $that )
Returns the remainder of the division of this number by this given one. The remainder has a scale of `max($this->scale, $that->scale)`.
public
# quotientAndRemainder( \BigNumber|\number|string $that )
Returns the quotient and remainder of the division of this number by the given one. The quotient has a scale of `0`, and the remainder has a scale of `max($this->scale, $that->scale)`.
public
# withPointMovedLeft( int $n )
Returns a copy of this BigDecimal with the decimal point moved $n places to the left.
public
# withPointMovedRight( int $n )
Returns a copy of this BigDecimal with the decimal point moved $n places to the right.
public
# stripTrailingZeros( )
Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part.
public
# abs( )
Returns the absolute value of this number.
public
# negated( )
Returns the negated value of this number.
public
# compareTo( $that )
{@inheritdoc}
public
# getSign( )
{@inheritdoc}
public
public
# getScale( )
public
# getIntegral( )
Returns a string representing the integral part of this decimal number. Example: `-123.456` => `-123`.
public
# getFraction( )
Returns a string representing the fractional part of this decimal number. If the scale is zero, an empty string is returned. Examples: `-123.456` => '456', `123` => ''.
public
# toBigInteger( )
{@inheritdoc}
public
# toBigDecimal( )
{@inheritdoc}
public
# toBigRational( )
{@inheritdoc}
public
# toScale( int $scale , int $roundingMode = 0 )
{@inheritdoc}
public
# toInt( )
{@inheritdoc}
public
# toFloat( )
{@inheritdoc}
public
# __toString( )
{@inheritdoc}
Methods inherited from Brick\Math\BigNumber
of(), min(), max(), isEqualTo(), isLessThan(), isLessThanOrEqualTo(), isGreaterThan(), isGreaterThanOrEqualTo(), isZero(), isNegative(), isNegativeOrZero(), isPositive(), isPositiveOrZero(), getSign(), compareTo(), toBigInteger(), toBigDecimal(), toBigRational(), toScale(), toInt(), toFloat(), __toString(), jsonSerialize()