關於部落格
  • 117911

    累積人氣

  • 1

    今日人氣

    0

    訂閱人氣

Note of Operation

Operator

指定算子, =
*. j=3 //指定 j 值為 3
*. (j=3) //運算式本身值也是 3
*. 後置結合率: i=j=3+5 意為 i = ( j = ( 3 + 5 ) )

數值算子(+,-,*,/,%)
*. a%b: a 除以 b 之餘數

遞增算子(i++,i--,++i,--i)
*. (Post Increment Operator, i++): 算完再加1
*. (Post Increment Operator, ++i): 加完1再算

Logical Operator
Let opr is a Operator.
*. Complement: !opr
*. Comparision: ==, !=, >, <, >=, <=)
*. Logical:( ^, &, |, &&, ||)
*. ^ is XOR ie. 不同為真
*. &, &&: AND
*. |, ||: OR
*. &, |: 左右運算結束再判斷
*. &&, ||: 左成立結束運算, Short Circuit(短路模式)

ex:
i=3; ( true | ( i++ == 4 ) ) is true but i is 4
i=3; ( true || ( i++== 4 ) ) is true but i is 3

Bitwise Operation

Logical Operator( &, l, ^ ): 逐項比照
*. 000 & 111 -> 000
Complement Operator( ~ ): 逐項逆
*. ~000 -> 111
Shift Operator
>>: 右位移, 補0, 最左值不變 ie. 正負不變
*. (11)1->1(11)
<<: 左位移, 補0.
*. 1(11)->(11)0
>>>: 右位移, 補0
*. (11)1->0(11)

(to be continue...)

See alo: Java_Note
相簿設定
標籤設定
相簿狀態