Oct 21, 2011 at 4:47pm UTC
I need a program that can count by changing the digits in a binary file example:
1111 1111 to 1111 1110 then 1111 1101 then 1111 1011
How could I do this?
Oct 21, 2011 at 9:28pm UTC
I mean shift 1111 1111 to 1111 1110 then it to 1111 1101 then to 1111 1011...etc.
Last edited on Oct 21, 2011 at 9:29pm UTC
Oct 21, 2011 at 10:59pm UTC
Have you ever heard of bit manipulation? It's only one of the most best features of C++, in my opinion. Here are some operations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
char Flags( 0x3 );
// Remove a bit:
Flags &= ~( 0x1 );
// Add a bit:
Flags |= ( 0x1 );
// Test a bit:
if ( Flags &( 0x1 ) ) { ... }
// Toggle a bit
Flags ^= ( 0x1 );
// Shift left:
Flags <<= 2;
// Shift right:
Flags >>= 2;
Edited in response to Disch's post :) Thanks for pointing them out, Disch.
Wazzak
Last edited on Oct 21, 2011 at 11:04pm UTC