Data structure type conversion elements

1, a data type conversion structure

1,1 arithmetic

Different types of operands, first automatically converted to an expression in the highest level of data type, then operation, operation results in the highest level of data type, referred to as low-level is automatically converted to a high level.

long lon=5+6+7L+'a';
double de=5+6.7*8+'a';

Note : byte+shortand short+charthe results obtained are inttype.

1,2 assignment operator

Automatic type conversion

Cast

Operators meaning Operational rule
& Bitwise AND Both operands are 1, the result is 1.
| Bitwise or 1 is a two operands, the result is 1.
^ Bitwise XOR The same two operands, the result is 0, and vice versa, is 1.
~ Non-bit Operand is 0, the result is 1. Operand 1, the result is zero.
<< The left 0 up right space.
>> Right Fill the vacancy left MSB, i.e. the sign bit.
>>> Unsigned right shift Fill vacancies left position.

 

例1:5&6

Example 2 : 5 | 6

Example 3 : Non-bit

Guess you like

Origin www.cnblogs.com/xiaozhuzhu-518013/p/11247176.html