BigNumber

Common interface for arbitrary-precision rational numbers.
implements JsonSerializable , Serializable

Known subclasses

Brick\Math\BigDecimal, Brick\Math\BigInteger, Brick\Math\BigRational
Abstract
Open source code
Methods Summary
public static
# of( \BigNumber|\number|string $value )
Creates a BigNumber of the given value. The concrete return type is dependent on the given value, with the following rules: - BigNumber instances are returned as is - integer numbers are returned as BigInteger - floating point numbers are returned as BigDecimal - strings containing a `/` character are returned as BigRational - strings containing a `.` character or using an exponentional notation are returned as BigDecimal - strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger
public static
# min( \BigNumber|\number|string $values ,… )
Returns the minimum of the given values.
public static
# max( \BigNumber|\number|string $values ,… )
Returns the maximum of the given values.
public
# isEqualTo( \BigNumber|\number|string $that )
Checks if this number is equal to the given one.
public
# isLessThan( \BigNumber|\number|string $that )
Checks if this number is strictly lower than the given one.
public
# isLessThanOrEqualTo( \BigNumber|\number|string $that )
Checks if this number is lower than or equal to the given one.
public
# isGreaterThan( \BigNumber|\number|string $that )
Checks if this number is strictly greater than the given one.
public
# isGreaterThanOrEqualTo( \BigNumber|\number|string $that )
Checks if this number is greater than or equal to the given one.
public
# isZero( )
Checks if this number equals zero.
public
# isNegative( )
Checks if this number is strictly negative.
public
# isNegativeOrZero( )
Checks if this number is negative or zero.
public
# isPositive( )
Checks if this number is strictly positive.
public
# isPositiveOrZero( )
Checks if this number is positive or zero.
abstract public
# getSign( )
Returns the sign of this number.
abstract public
# compareTo( \BigNumber|\number|string $that )
Compares this number to the given one.
abstract public
# toBigInteger( )
Converts this number to a BigInteger.
abstract public
# toBigDecimal( )
Converts this number to a BigDecimal.
abstract public
# toBigRational( )
Converts this number to a BigRational.
abstract public
# toScale( int $scale , int $roundingMode = 0 )
Converts this number to a BigDecimal with the given scale, using rounding if necessary.
abstract public
# toInt( )
Returns the exact value of this number as a native integer. If this number cannot be converted to a native integer without losing precision, an exception is thrown. Note that the acceptable range for an integer depends on the platform and differs for 32-bit and 64-bit.
abstract public
# toFloat( )
Returns an approximation of this number as a floating-point value. Note that this method can discard information as the precision of a floating-point value is inherently limited.
abstract public
# __toString( )
Returns a string representation of this number. The output of this method can be parsed by the `of()` factory method; this will yield an object equal to this one, without any information loss.
public
# jsonSerialize( )
{@inheritdoc}

Implementation of