G
G Iveco
I am using this type of code to do right-shifting,
B = 3;
data1 = (data + (1 << (B-1))) >> B;
data1 seems incorrect when data = -4-8*i.. which means it
rounds -1.5 to -1 instead of -2.
On the positive side, 1.5 is rounded to 2, which ic correct.
For left-shift, it's simply as follows, no pitfalls, am I right?
data1 = data << B;
Thanks.
B = 3;
data1 = (data + (1 << (B-1))) >> B;
data1 seems incorrect when data = -4-8*i.. which means it
rounds -1.5 to -1 instead of -2.
On the positive side, 1.5 is rounded to 2, which ic correct.
For left-shift, it's simply as follows, no pitfalls, am I right?
data1 = data << B;
Thanks.