We're lucky Python's "round" already implements those stuff for us :)
I've build a test that check if the rounding function works for the algorithm you provided (i've used log2, seems to run a little faster) - and, most importantly fails when provided any of the previous algorithms.
We're lucky Python's "round" already implements those stuff for us :)
I've build a test that check if the rounding function works for the algorithm you provided (i've used log2, seems to run a little faster) - and, most importantly fails when provided any of the previous algorithms.
http:// pastebin. com/ZMHqyC0e