mini\Util\Math\DecimalMath final class

Documentation

Arbitrary precision decimal math using integer math with scaling

Stores decimals as strings (e.g., "123.456") and internally converts to scaled integers for arithmetic, then converts back.

Usage: DecimalMath::add('10.50', '3.25') // "13.75" DecimalMath::multiply('10.5', '2') // "21" DecimalMath::divide('10', '3', 4) // "3.3333"

Methods (14)

Add two decimals

Subtract b from a

Multiply two decimals

Divide a by b with specified precision

Modulus (remainder after integer division)

Compare two decimals: -1 if a < b, 0 if equal, 1 if a > b

Check if value is zero

Round a decimal to specified scale

Convert decimal string to scaled integer and its scale

Align two decimals to the same scale, returning their scaled integer forms

Pad integer string with zeros on the right (handles negatives)

Insert decimal point into scaled integer

Source

src/Util/Math/DecimalMath.php:16-273