Answer the question
In order to leave comments, you need to log in
How to "insert" bits into a number?
Let's say there is a number:
0000 0000 0100 0100
Variable 2 bytes.
Suppose we need to "insert" zero in the last 8 bits so that it is in positions with numbers equal to powers of two. We have the first 8 bits in reserve, because the result will "increase" by 4 bits.
That is, as a result, you should get:
0000 00 0 0 100 0 0100
Figuratively speaking, somehow you need to shift some of the bits to the left several times, thereby creating new bits in the right positions.
How to implement? give a hint.
Upd C language
Answer the question
In order to leave comments, you need to log in
Depends on the programming language. For example in Cy = ((x&0xF0)<<4)|((X&0x0E)<<3)|((x&1)<<2);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question