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.

Blimey, I should really know how to do this - I seem to be suffering from brainfade today. :/

Anyway, given a random integer value, how would you calculate the next highest ^2 value, but only if the value isn't already a ^2 number?

I did come up with the following - which I cobbled together from stuff in the docs. It seems to work, but I'm not too sure how (maths not being my favourite subject) :P

Function pow2(x)
  Return 1 Shl (Ceil(Log(x) / Log(2)))
End Function


So, is there a simpler way?