what's the easiest way to round up to power of 2?

BlitzMax Forums/BlitzMax Programming/what's the easiest way to round up to power of 2?

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.

this should be the fastest solution...
Function p:Int( n:Int )
	n :- 1
	n :| (n Shr 1)
	n :| (n Shr 2)
	n :| (n Shr 4)
	n :| (n Shr 8)
	n :| (n Shr 16)
	Return n+1
End Function

might have to be reversed on a powerpc mac though.