Things that are easy to ignore in C language [uncommon bit domains]

Source: Internet
Author: User
Tags domain list

There are very few courses in the university that focus on the domain or even bit operators. In fact, bit operations may play a key role in algorithm optimization. & Bitwise AND | bitwise OR ^ bitwise OR ~ Bitwise inversion <left shift> shifts right are six operators. What is a bitfield? Sometimes the storage of information does not require a complete byte, but only takes up to a few or even a binary bit. To this end, a bit domain was born to save storage space and simplify data processing. Definition method: struct bit domain structure name {bit domain list}; for example, [cpp] struct bit {int x: 8; // The length is 8 int y: 2; // The length is 2 int z: 6 // The length is 6}. The preceding y and z are actually stored in one byte, but one bit field must be stored in one byte, it cannot boast bytes. If the length of z is 7, the storage of z will create a new byte. You can also customize a new byte, and use the airspace: [cpp] int: 0; www.2cto.com bit domain can be a non-bit domain name, such a bit domain is used to fill or adjust the location, because there is no name, [cpp] int: 2; [cpp] // method bit cannot be used. x = 1; bit. y = 1; bit. z = 1;

Related Article

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.