View Single Post
Old 06-08-2004, 07:56 AM  
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
Programming Problem - Help

I'm doing somethere where a selected value HAS to be an integer power of 2. Anyone know a "clean" way I could round a desired value to the nearest power of 2?

I.e. input is 37 -> rounded to 32

input is 84 - > rounded to 64

input is 99 -> rounded to 128


Just a general algo is fine, i can adapt it to PHP.
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote