less than 1 minute read

Fix Ubuntu not responding, base 10 log in python

If our ubuntu desktop stops responding by not registering mouse clicks or keyboard shortcuts like super or alt-tab anymore but background processes keep running like music on chrome etc. Then do Alt+PrntScrn and type R E I S U B, Alt+PrntScrn seems to take a screenshot but it does bring the system back to life (!?).

In python if we want to calculate the log base 10 of something we should use math.log10(x) instead of using math.log(x, 10). This is because due to some rounding errors and whatnot math.log(1000000, 10) = 5.9999999 instead of being in the range 6 -> 6.99999999. Which I was expecting since for other inputs like math.log(10000000, 10) = 7.0 and math.log(99999999, 10) = 7.99999. The log base 10 seems to be within the floor which correspond to the number of digits in x but it failed. So using math.log(1000000) = 6 correctly returns 6 instead of 5.999999. This problem came up when working on EPI 4.9 Is Number Palindrome.