[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/brick/math/src/ -> BigDecimal.php (summary)

Immutable, arbitrary-precision signed decimal numbers.

File Size: 855 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 40 functions

  __construct()
  of()
  ofUnscaledValue()
  zero()
  one()
  ten()
  plus()
  minus()
  multipliedBy()
  dividedBy()
  exactlyDividedBy()
  power()
  quotient()
  remainder()
  quotientAndRemainder()
  sqrt()
  withPointMovedLeft()
  withPointMovedRight()
  stripTrailingZeros()
  abs()
  negated()
  compareTo()
  getSign()
  getUnscaledValue()
  getScale()
  getIntegralPart()
  getFractionalPart()
  hasNonZeroFractionalPart()
  toBigInteger()
  toBigDecimal()
  toBigRational()
  toScale()
  toInt()
  toFloat()
  __toString()
  serialize()
  unserialize()
  scaleValues()
  valueWithMinScale()
  getUnscaledValueWithLeadingZeros()

Functions
Functions that are not part of a class:

__construct(string $value, int $scale = 0)   X-Ref
Protected constructor. Use a factory method to obtain an instance.

param: string $value The unscaled value, validated.
param: int    $scale The scale, validated.

of($value)   X-Ref
Creates a BigDecimal of the given value.

param: BigNumber|int|float|string $value
return: BigDecimal

ofUnscaledValue($value, int $scale = 0)   X-Ref
Creates a BigDecimal from an unscaled value and a scale.

Example: `(12345, 3)` will result in the BigDecimal `12.345`.

param: BigNumber|int|float|string $value The unscaled value. Must be convertible to a BigInteger.
param: int                        $scale The scale of the number, positive or zero.
return: BigDecimal

zero()   X-Ref
Returns a BigDecimal representing zero, with a scale of zero.

return: BigDecimal

one()   X-Ref
Returns a BigDecimal representing one, with a scale of zero.

return: BigDecimal

ten()   X-Ref
Returns a BigDecimal representing ten, with a scale of zero.

return: BigDecimal

plus($that)   X-Ref
Returns the sum of this number and the given one.

The result has a scale of `max($this->scale, $that->scale)`.

param: BigNumber|int|float|string $that The number to add. Must be convertible to a BigDecimal.
return: BigDecimal The result.

minus($that)   X-Ref
Returns the difference of this number and the given one.

The result has a scale of `max($this->scale, $that->scale)`.

param: BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigDecimal.
return: BigDecimal The result.

multipliedBy($that)   X-Ref
Returns the product of this number and the given one.

The result has a scale of `$this->scale + $that->scale`.

param: BigNumber|int|float|string $that The multiplier. Must be convertible to a BigDecimal.
return: BigDecimal The result.

dividedBy($that, ?int $scale = null, int $roundingMode = RoundingMode::UNNECESSARY)   X-Ref
Returns the result of the division of this number by the given one, at the given scale.

param: BigNumber|int|float|string $that         The divisor.
param: int|null                   $scale        The desired scale, or null to use the scale of this number.
param: int                        $roundingMode An optional rounding mode.
return: BigDecimal

exactlyDividedBy($that)   X-Ref
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.

param: BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
return: BigDecimal The result.

power(int $exponent)   X-Ref
Returns this number exponentiated to the given value.

The result has a scale of `$this->scale * $exponent`.

param: int $exponent The exponent.
return: BigDecimal The result.

quotient($that)   X-Ref
Returns the quotient of the division of this number by this given one.

The quotient has a scale of `0`.

param: BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
return: BigDecimal The quotient.

remainder($that)   X-Ref
Returns the remainder of the division of this number by this given one.

The remainder has a scale of `max($this->scale, $that->scale)`.

param: BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
return: BigDecimal The remainder.

quotientAndRemainder($that)   X-Ref
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)`.

param: BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
return: BigDecimal[] An array containing the quotient and the remainder.

sqrt(int $scale)   X-Ref
Returns the square root of this number, rounded down to the given number of decimals.

param: int $scale
return: BigDecimal

withPointMovedLeft(int $n)   X-Ref
Returns a copy of this BigDecimal with the decimal point moved $n places to the left.

param: int $n
return: BigDecimal

withPointMovedRight(int $n)   X-Ref
Returns a copy of this BigDecimal with the decimal point moved $n places to the right.

param: int $n
return: BigDecimal

stripTrailingZeros()   X-Ref
Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part.

return: BigDecimal

abs()   X-Ref
Returns the absolute value of this number.

return: BigDecimal

negated()   X-Ref
Returns the negated value of this number.

return: BigDecimal

compareTo($that)   X-Ref
{@inheritdoc}


getSign()   X-Ref
{@inheritdoc}


getUnscaledValue()   X-Ref

return: BigInteger

getScale()   X-Ref

return: int

getIntegralPart()   X-Ref
Returns a string representing the integral part of this decimal number.

Example: `-123.456` => `-123`.

return: string

getFractionalPart()   X-Ref
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` => ''.

return: string

hasNonZeroFractionalPart()   X-Ref
Returns whether this decimal number has a non-zero fractional part.

return: bool

toBigInteger()   X-Ref
{@inheritdoc}


toBigDecimal()   X-Ref
{@inheritdoc}


toBigRational()   X-Ref
{@inheritdoc}


toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY)   X-Ref
{@inheritdoc}


toInt()   X-Ref
{@inheritdoc}


toFloat()   X-Ref
{@inheritdoc}


__toString()   X-Ref
{@inheritdoc}


serialize()   X-Ref
This method is required by interface Serializable and SHOULD NOT be accessed directly.

return: string

unserialize($value)   X-Ref
This method is only here to implement interface Serializable and cannot be accessed directly.

param: string $value
return: void

scaleValues(BigDecimal $x, BigDecimal $y)   X-Ref
Puts the internal values of the given decimal numbers on the same scale.

param: BigDecimal $x The first decimal number.
param: BigDecimal $y The second decimal number.
return: array{0: string, 1: string} The scaled integer values of $x and $y.

valueWithMinScale(int $scale)   X-Ref

param: int $scale
return: string

getUnscaledValueWithLeadingZeros()   X-Ref
Adds leading zeros if necessary to the unscaled value to represent the full decimal number.

return: string



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer