Optimised the code for 10-15% speedup. Instead of creating a string it just uses Long.highestOneBit method.
Optimised heavily to stop repeat calculations
Optimised for speedup