Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'>>>' Java to C++ [duplicate]

Tags:

c++

shift

Possible Duplicate:
What is >>> operation in C++

I need to convert this tiny little part of Java to C + +, but do not know what is '>>>' ... searched, but found no references, only on shift. Does anyone have any ideas?

int x1;

x1 = text1[i1++] & 0xff;

text2[i2++] = (char) (x1 >>> 8); 
like image 960
Daniel Gariani Rafael Avatar asked Sep 08 '26 21:09

Daniel Gariani Rafael


1 Answers

The unsigned right shift (>>>) doesn't exist in C++, because it's not necessary -- C++ has distinct signed and unsigned integer types. If you want right shifts to be unsigned, make the variable that's being shifted unsigned:

unsigned int x1 = text1[i1++] & 0xff;
text2[i2++] = (char) (x1 >> 8);

That being said, the code you're translating is silly. The result of the second operation will always be zero in Java, so you could just as easily translate it to:

i1++;
text2[i2++] = 0;

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!