Best way to calc next ^2 value...

Blitz3D Forums/Blitz3D Programming/Best way to calc next ^2 value...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

That formula is correct. I haven't been able to think of anything simpler. I prefer verbose function names and called mine round_up_to_a_power_of_two(). :)

"log(x)/log(2)" tells you to what power you'd need to raise 2 to get x

"ceil()" rounds it up to a whole number

"1 shl y" is a sneaky bitwise way to raise 2 to the power of y