开发者

what does (x<<13) ^ x mean?

开发者 https://www.devze.com 2023-02-28 11:07 出处:网络
What language is this expression and what does it mean? x 开发者_JAVA技巧= (x << 13) ^x; It could be any number of languages.In C and several other languages, << is a left-shift operator

What language is this expression and what does it mean?

x 开发者_JAVA技巧= (x << 13) ^x;


It could be any number of languages. In C and several other languages, << is a left-shift operator, and ^ is a bitwise XOR operator.


Both << and ^ ( left-shift and xor respectively) are bitwise operators and many languages like C, C++, Java have them

http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Bitwise_operators


In C, this would be "left shift x by 13 binary places, and take the XOR of this and x".


It is any C-derived language.

It means that the author only knows part of C. Otherwise they’d’ve written

 x ^= x << 13;

to xor something with itself multiplied by 2¹³.


What language is this expression

That is C syntax. This could be any C-based programming language (C, C++, C#, Java, JavaScript). However, this is not PHP or Perl because sigils are not used.

what does it mean?

I actually can't read that code either - syntactic languages such as C are very hard to read. From what I understand from what other people said this is equivalent to:

(bit-xor (bit-shift-left x 13) x)
0

精彩评论

暂无评论...
验证码 换一张
取 消