Learn how to use groovy (chapter 1 of translation)

Source: Internet
Author: User

There is nothing to say. You can understand it at a glance.

Bitwise operations  

From groovy 1.0 Beta 10, groovy supports bitwise operations: (supported from grovvy1.0beta10)
<.>, >>>, |, &, ^, And ~.

  _Meaning_
< Bitwise left shift operator
> Bitwise right shift operator
>>> Bitwise unsigned right shift operator
| Bitwise OR operator
& Bitwise AND operator
^ Bitwise XOR operator
~ Bitwise negation Operator
<= Bitwise left shift assign Operator
>>= Bitwise right shift assign Operator
>>>= Bitwise unsigned right shift assign Operator
| = Bitwise OR assign Operator
& = Bitwise AND assign Operator
^ = Bitwise XOR operator

For example,

  assert  (1 <2) = 4  // bitwise left shift   assert  (4>> 1) = 2  // bitwise right shift   assert  (15>> 1) = 7  // bitwise unsigned right shift   assert  (3 | 6) = 7  // bitwise OR   assert  (3 & 6) = 2  // bitwise AND   assert  (3 ^ 6) = 5  // bitwise XOR   assert  (~ 0 xfffffffe) = 1  // bitwise negation  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.