Code: b = 1 << 1 | 1;use instead:Code: b = (b << 1) | 1;to produce 0b00000001 -> 0b00000011 -> 0b00000111 ...or Code: b = (b >> 1) | 0x80;to produce 0b10000000 -> 0b11000000 -> 0b11100000 ...;This is also considerably faster.
I have just tested that and yes it does work, great. What is the -1 doing in this if you don't mind me asking (i have not used these functions before so this is new to me)? If am going to use it i need to know what it is doing lol but thanks a bunch to WizenedEE and Grumpy_Mike.
1<<5 = 0010000000100000 -1 = 00011111~00011111 = 11100000
What is the -1 doing
b = ~b; // note this is a tilda not a miniusb = b ^ 0xff // exclusive or inverts all bits in a variable that have a matching one in the number you are exoring it withb = not(b);