Math

Arbitrary precision arithmetic on non-negative decimal integer strings.

Namespace: Com\Tecnick\Barcode

final class Math

Source: src/Math.php:36

Arbitrary precision arithmetic on non-negative decimal integer strings. The bcmath extension is used when available, otherwise the equivalent pure-PHP implementation is used, so bcmath is an optional dependency.

Methods

add()

Add two non-negative decimal integers.

public static add(string $left, string $right): numeric-string

Parameters:

  • $left (string): First operand
  • $right (string): Second operand

Returns: numeric-string

Source: src/Math.php:71

div()

Integer division of two non-negative decimal integers.

public static div(string $left, string $right): numeric-string

Parameters:

  • $left (string): Dividend
  • $right (string): Divisor

Returns: numeric-string

Source: src/Math.php:105

fallbackAdd()

Add two non-negative decimal integers without bcmath.

public static fallbackAdd(string $left, string $right): numeric-string

Parameters:

  • $left (string): First operand
  • $right (string): Second operand

Returns: numeric-string

Source: src/Math.php:139

fallbackDiv()

Integer division of two non-negative decimal integers without bcmath.

public static fallbackDiv(string $left, string $right): numeric-string

Parameters:

  • $left (string): Dividend
  • $right (string): Divisor

Returns: numeric-string

Source: src/Math.php:221

fallbackMod()

Remainder of the integer division of two non-negative decimal integers without bcmath.

public static fallbackMod(string $left, string $right): numeric-string

Parameters:

  • $left (string): Dividend
  • $right (string): Divisor

Returns: numeric-string

Source: src/Math.php:234

fallbackMul()

Multiply two non-negative decimal integers without bcmath.

public static fallbackMul(string $left, string $right): numeric-string

Parameters:

  • $left (string): First operand
  • $right (string): Second operand

Returns: numeric-string

Source: src/Math.php:174

hasBcmath()

Returns true if the bcmath functions are available.

public static hasBcmath(): bool

Returns: bool

Source: src/Math.php:54

mod()

Remainder of the integer division of two non-negative decimal integers.

public static mod(string $left, string $right): numeric-string

Parameters:

  • $left (string): Dividend
  • $right (string): Divisor

Returns: numeric-string

Source: src/Math.php:122

mul()

Multiply two non-negative decimal integers.

public static mul(string $left, string $right): numeric-string

Parameters:

  • $left (string): First operand
  • $right (string): Second operand

Returns: numeric-string

Source: src/Math.php:88