![]() |
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. |
think in binary
|
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 |
Quote:
|
Quote:
blazin: Thanks, I will :D |
All times are GMT -7. The time now is 03:06 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123