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<< <<