File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,20 @@ $decimalAdded = $decimalOne->add($decimalTwo); // Now '3.3'
8080
8181Note that due to immutability ` $decimalOne ` is not modified here. The re-assignment is necessary for the operation to persist.
8282
83+ ### Precision/Scale
84+ Operations like ` add() ` use the higher of the scales of the operands.
85+ If both are the same, they would also stay the same.
86+
87+ With other operations like ` multiply() ` , they scale would be the addition of both operands' scale:
88+ ``` php
89+ $decimalOne = Decimal::create('1.55');
90+ $decimalTwo = Decimal::create('2.00');
91+
92+ echo $decimalOne->multiply($decimalTwo); // Prints '3.1000'
93+
94+ // Keeping 2 digit scale requires a 2nd argument
95+ echo $decimalOne->multiply($decimalTwo, 2); // Prints '3.10'
96+ ```
8397
8498## Contributing
8599
You can’t perform that action at this time.
0 commit comments