C/C ++

Source: Internet
Author: User

C/C ++ supports the following operations:

<1> bitwise operators (Note: The following operators do not change the value of the original variable, but get the result of the operation as a new value)

<2> Bit Field

The following C ++ code:

 a: b: c: d:

 

A bit field is declared by a structure that provides tags for each field and determines the width of the label field.

The preceding unsigned int is used as the basic layout unit of the bit field structure. Therefore, even if a structure has only one member field, the structure is the same as the size of an unsigned int, the above sizeof is regarded as 8, and the machine sizeof (unsigned int) is 4. If the last one is changed to d: 20, the current machine's sizeof is exactly 4.

 

In addition, add 0x to the hexadecimal front and 0 to the octal front.

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------

1. Write a function and return the number of digits specified after the given number. That is, 0 is changed to and 0 is changed.

Ideas:

~ It is inappropriate to reverse all bits of the entire number. returns the given value and the number of digits after the given value are all 1, and the number of digits left before the given value is 0 ^.

The key is how to obtain the number of digits after which is all 1?

#include <iostream>  invert_end( num, bits)     mask=;        temp=;         (bits>=mask|temp;           temp=temp<<;            bits-- num^mask;    main(<<()<<<<>> res=invert_end(val,<<val<<  << 

 

 

 

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.