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
fix typo
Merge pull request #7 from waldyrious/master

fix two bugs in the smart rounding code