Bitwise NOT? NOT! Not sure which way to convert this...
Oldbitcollector (Jeff)
Posts: 8,091
I thought at first what I was trying to do is a bitwise NOT.. After scanning the Propeller Manual and a quick test, this isn't what I'm trying to accomplish.
If I've got a binary number that looks like this: 10010000
I need that number to look like this: 00001001
Bitwise NOT returns: 111101110 I'm trying to flip the number completely over.
Can someone tell me what type of bit shift I'm attempting here?
Thanks
Jeff
If I've got a binary number that looks like this: 10010000
I need that number to look like this: 00001001
Bitwise NOT returns: 111101110 I'm trying to flip the number completely over.
Can someone tell me what type of bit shift I'm attempting here?
Thanks
Jeff
Comments
I assume you mean 00001001 not 000010001 - you got nine bits there bud!
I needed to read a little further in.. Propeller Manual, Page 163.. Bitwise Reverse >< 8
Spin is just freak'n awesome..
x ><= 8
Will flip reverse the last 8 bits.
Edit: You find it. Bitwise reverse. Yeah, that's what it's called.
I have no idea if there is a REV operator in Spin.
Or you can adapt this solution to Spin: http://stackoverflow.com/questions/746171/best-algorithm-for-bit-reversal-from-msb-lsb-to-lsb-msb-in-c
http://www.geeksforgeeks.org/write-an-efficient-c-program-to-reverse-bits-of-a-number/
Amen Brother!