Created
September 18, 2014 18:38
-
-
Save jarvist/368622717a5d3bcadfc0 to your computer and use it in GitHub Desktop.
Maximum coverage for loops; bit reversing integars http://jarvistmoorefrost.wordpress.com/2014/09/18/maximum-coverage-for-loops-bit-reversing-integars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (i=0;i<256;i++) | |
{ | |
// Alright, this is the plan | |
// First we take our variable | |
// Then we bit reverse it as binary | |
// Pretty confusing, but means it will fill in the temperature | |
// range with maximum coverage, rather than linear ramping | |
unsigned char r=i; | |
r=(r&0xF0)>>4 | (r&0x0F)<<4; | |
r=(r&0xCC)>>2 | (r&0x33)<<2; | |
r=(r&0xAA)>>1 | (r&0x55)<<1; | |
...Do some science... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment