The equivalent of the C shift operator in Java?

C shift operator < do not loop, for example, if you do this:

// C++
int a = 1;
cout << (a<<38);

You get 0 However, in Java, you actually loop and get a valid value of 64

I need to translate some C code into Java, so what do I use as <

Solution

Java language spec says:

So, in your example, (int) ((long) a) < 38) should work

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>