& Is a binary bitwise AND operator;
~ Is a binary bitwise inverse operator.
Generation: If (Oldfont. Bold)
{
// If it is a black image, the system removes the manual configuration.
Newfont = New Font (oldfont, oldfont. Style & ~ Fontstyle. Bold );
}
Else
{
// If it is not a hacker, add the hacker
Newfont = New Font (oldfont, oldfont. Style | Fontstyle. Bold );
}
Solution:
In fact, fontstyle is a binary number. Assume that the first digit is italic, that is, 000001 is italic, and the second digit is bold, that is, 000010 is bold, and 000011 is bold and oblique.
First, we get the inverse of 000010 in bold, and then we get 111101, and then perform bitwise AND with a style. The characteristic of bitwise AND is that if one of the first and second binary numbers is 1, the result is 1. Obviously, if any number and 111101 are bitwise, the result is 0 at the second position, which achieves the effect of removing the black body.
Http://topic.csdn.net/t/20061119/17/5169316.html: