File tree 1 file changed +14
-0
lines changed
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'
80
80
81
81
Note that due to immutability ` $decimalOne ` is not modified here. The re-assignment is necessary for the operation to persist.
82
82
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
+ ```
83
97
84
98
## Contributing
85
99
You can’t perform that action at this time.
0 commit comments