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 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 ) ) ); 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
Archived
This topic is now archived and is closed to further replies.