Question: In C++ a= In C++ In base -2, integers are represented by sequences of bits in the following way. Bits are ordered from the least
In C++

a=
In C++
In base -2, integers are represented by sequences of bits in the following way. Bits are ordered from the least to the most significant. Sequence B of N bits represents the number: sum{ B[i]*(-2)' for i = 0...N-1}. The empty sequence represents 0. For example: 100111 represents -23 001011 represents -12 10011 represents 9 represents 4, because: 001 1 | -2 4 -8 16 -32 --- -- 1 1 = 1 + 0 + 0 + (-8) + 16 = -23 | 1 0 + 0 + 4 + + 16 1 | 0 0 | 1 1 + (-32) 100 | 10 | 1 + (-32) = -12 | 10 | 0 | 1 | 1 = 9 100 | 1 | = 4 1 + | = 1 + 0 + 0 + (-8) + 16 | = 0 + 0 + 4 Note that such a representation is suitable for both positive and negative integers. Write a function: vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
