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)))
Post a Comment
2 comments:
a simple one i think is like this
nextmul = num + (num &7)
sorry a modification to my earlier answer
nextmul8 = 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)))
Post a Comment