A blog dedicated to those who live, drink and eat Algorithms.
a simple one i think is like this nextmul = num + (num &7)
sorry a modification to my earlier answernextmul8 = 8 + (num - (num & 7))this can be genralised for any power of 2 numberx is power of 2nextmulofx = x+ (numinput - (numinput & (x-1)))
a simple one i think is like this
ReplyDeletenextmul = num + (num &7)
sorry a modification to my earlier answer
ReplyDeletenextmul8 = 8 +
(num - (num & 7))
this can be genralised for any power of 2 number
x is power of 2
nextmulofx
= x+ (numinput - (numinput & (x-1)))