| 
		
			
			
				
			
			
				 
			
			
				
			
		 | 
		
			
			
				 
			
				
			
		 | 
	||||
| 
				Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.  You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us.  | 
		
		 
		![]()  | 
	
		
			
  | 	
	
	
		
		|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. | 
| 
		 | 
	Thread Tools | 
| 
			
			 | 
		#1 | 
| 
			
			
			
			 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.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Aug 2002 
				
				
				
					Posts: 2,781
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 think in binary 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Feb 2003 
				
				
				
					Posts: 6,040
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Alright, this might not be the cleanest approach, by try something like this. 
		
	
		
		
		
		
		
	
	A=2 While A is less than Input A = A*2 Wend Edit: Input = A/2  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#4 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Nov 2003 
				
				
				
					Posts: 4,292
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#5 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Aug 2002 
				Location: East Coast. 
				
				
					Posts: 2,251
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 blazin: Thanks, I will :D  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 |