fix two bugs in the smart rounding code

- the output of digits() is ordered from the least significant to the most, so it needs to be reversed
- fix a copy-paste overlook: log to log10
- also, add some code comments