C = (A<<4) | B ;
Thank you for this information, but I need a little clarification because I do not understand exactly how this operator works.If you know the length of the strings you can combine them with shifting and boolean operations.
With strings you need to use library functions. There are no string concatenation operators in C. Literal strings can be concatenated explicitly as initializers or printf arguments.Rich (BB code):C = (A<<4) | B ;
No No No. Shifting is NOT the same as rotating! Bits shifted right past the least significant bit just disappear. Similarly bits shifted left past the most significant bit also disappear, by falling into the bit-bucket.So from this 0b00000001 >>4
I get this: 0b00010000 ?
It is difficult to test it with the compiler with no display and I do not want to connect a virtual teminal just to check.
No I do not mean binary plus. OR is a boolean operation that takes place on a bit by bit basis with no carries. The truth table looks like:By OR you mean binary plus.
So we have 0b00010000 + 0b00000001?
That truth table is similar to binary summing.No I do not mean binary plus. OR is a boolean operation that takes place on a bit by bit basis with no carries. The truth table looks like:
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1
Just because two things are similar, does make them equivalent. We have a number of different operations because there are different behaviors we need to use.That truth table is similar to binary summing.
1+1=0 remainder 1
0+0=0 remainer 0
1+0=1 remainder 0
0+1=1 remainer 0
That is why I ask.
I need to sum two binary numbers like this:
0b00010000+ 0b00001000
I changed your numbers. Zero isn't interesting.A = 1111
B = 0001
C = A & B
C now equals 11110001
by Luke James
by Luke James