M.-A. Lemburg wrote: > You often have a need for controlled rounding when doing > financial calculations You should NOT be using binary floats for money in the first place. > or in situations where you want to > compare two floats with a given accuracy, Pseudo-rounding to decimal places is not the right way to do that. The right way is to compare the difference to a tolerance. > e.g. to work > around rounding problems ;-) As Tim Peters has pointed out many times, you can't fix binary/decimal representation problems by rounding. There are always cases that give a different result than you would want. > Hmm, looks like a YAGNI to me, In all my programming so far I've found numerous uses for round-to-int, and exactly zero uses for round-binary-float-to-decimal- places. So from my point of view, the YAGNI applies to the *current* behavour of round()! -- Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4