|
|
|
|
|
by wiz21c
1817 days ago
|
|
Using float is perfectly OK since using fixed point decimal (or whatever "exact" math operations) will lead to rounding error anyway (what about multiplying a monthly salary by 16/31 (half a month) ?) The problem with float is that many people don't understand how they work to handle rounding errors correctly. Now there are some cases where float don't cut it. And big ones. For example, summing a set of numbers (with decimal parts) will usually be screwed if you don't round it. And not many people expect to round the results of additions because they are "simple" operations. So you get errors in the end. (I have written applications that handle billions of euros with floats and have found just as many rounding errors there as in any COBOL application) |
|
https://docs.python.org/3/library/decimal.html
If it were me, I wouldn't go around bragging about how much money my software manages while being willfully ignorant of the fundamentals.