glenelkins Posted April 6, 2009 Share Posted April 6, 2009 hi how can i find the nearest, next power of 2 to a number. for example, if i start with 9 the next power of 2 is 16. $p = pow ( 2, ceil( log( $x) ) / log( 2 ) ); ^ above doesnt work Quote Link to comment https://forums.phpfreaks.com/topic/152756-solved-nearest-power-of-2/ Share on other sites More sharing options...
sasa Posted April 6, 2009 Share Posted April 6, 2009 $p = pow ( 2, ceil( log( $x) / log( 2 ) ) ); Quote Link to comment https://forums.phpfreaks.com/topic/152756-solved-nearest-power-of-2/#findComment-802282 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.