gunw avatar

[Grammer] 23 - Bitwise Operators, 24 - Identity Operator

gunw

Published: 25 Jan 2019 › Updated: 25 Jan 2019[Grammer] 23 - Bitwise Operators, 24 - Identity Operator

[Grammer] 23 - Bitwise Operators, 24 - Identity Operator

  • Bitwise Operators
    메모리에 저장된 실제 비트를 다룸. 연산 속도가 빠르고 코드가 짧음.
    비트 연산은 정수만 가능함.(실수 x, 문자열x)
    &, |, ^, ~, <<, >>
    a : 0 0 1 0 0 0 1 1
    b : 0 0 0 1 1 0 1 0
    & : 0 0 0 0 0 0 1 0 (AND)
    | : 0 0 1 1 1 0 1 1 (OR)
    ^ : 0 0 1 1 1 0 0 1 (XOR)
    ~ (NOT)
    a << n : a * (2^n)
    a >> n : a / (2^n)

  • Identity Operator(항등 연산자) : ===, !== 사용, 클래스 타입의 값을 비교

class A { }
let a = A()
let b = a
let c = A()

a === b // true
a === c // false

Leave [Grammer] 23 - Bitwise Operators, 24 - Identity Operator to:

Written by

User

Read more #swift4 posts


Best Posts From gunw

We have not curated any of gunw's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From gunw