You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,32 @@ When calculating these functions you need to specify the number of digits you ne
162
162
163
163
The `MathContext` contains a precision and information on how to round the last digits, so it is an obvious choice to specify the desired precision of mathematical functions.
164
164
165
+
#### Why is there no `setMathContext()` so I do not have to pass `MathContext` all the time?
166
+
167
+
Maintaining a static default `MathContext` would simplify calling the mathematical functions but it would make the static class stateful
168
+
which is a terrible thing. Imagine two parts of your programming setting the precision differently and the debugging mess you have afterwards, especially if they run in parallel threads.
169
+
170
+
But there is a trivial solution that might work perfectly fine for your project.
171
+
172
+
Write your own little wrapper class with your own hardcoded precision.
173
+
This is stable, simple, thread-safe and self-documenting.
0 commit comments