✍️
TIL
  • TIL
  • react
    • react 16.3 이후 라이프 싸이클
    • 함수형 컴포넌트 vs 클래스 컴포넌트
    • React의 장점
    • 기본문법
    • Flow Diagram
    • redux-saga
    • nextjs
    • mobx
    • 리액트는 어떻게 동작할까?
  • data-structure
    • 이진 검색 트리(binary search tree)
    • HashTable
    • Tree
    • 트라이(Trie)
    • 선형 구조 vs 비선형 구조
    • 연결 리스트(linked-list)
    • Queue
    • Graph
    • Heap
    • Stack
  • web
    • 웹 브라우저의 동작 원리
    • Basic
    • Webpack이란?
    • rendering
    • npm
    • babel
  • graphQL
    • Query
    • Mutation
    • Introduction
  • algorithm
    • big-o
    • 버블 정렬(bubble sort)
    • 힙 정렬(heap sort)
    • 선택 정렬(selection sort)
    • 퀵 정렬(quick sort)
    • 백트래킹 알고리즘
    • 삽입 정렬(insertion sort)
    • 계수 정렬(counting sort)
    • 다엑스트라 알고리즘
    • 이진 탐색
    • 합병 정렬(merge-sort)
    • 동적 계획법(Dynamic programming)
  • web-security
    • XSS(Cross Site Scripting)
    • CSRF(Cross-site request forgery)
    • Tabnabbing
  • javaScript
    • dom
    • 자바스크립트 성능 최적화
    • Event Loop
    • Snippets
    • javaScript
  • programming-paradigm
    • Object Oriented Programming
    • 함수형 프로그래밍
    • 구조적 프로그래밍
  • computer-science
    • Process vs Thread
    • 비트 연산자
    • 그레이 코드
  • vue
    • Vue
  • design-pattern
    • MVP pattern
    • Flux
    • 아토믹 디자인
    • MVVM pattern
    • MVC pattern
  • css
    • css
    • Grid
    • css-methodologies
    • FlexBox
  • html
    • html
  • regExp
    • regExp
  • git
    • Git-flow
Powered by GitBook
On this page
  • & (AND)
  • | (OR)
  • ^ (XOR)
  • ~ (NOT)
  • \<\< (부호 유지 왼쪽 시프트)
  • >> (부호 유지 오른쪽 시프트)
  • >>> (부호 버림 오른쪽 시프트)

Was this helpful?

  1. computer-science

비트 연산자

& (AND)

피연산자를 비트로 바꿨을 때 각각 대응하는 비트가 모두 1이면 그 비트값에 1을 반환

console.log(3 & 5) // 011 & 101 = 1
console.log(3 & 4) // 011 & 100 = 0

| (OR)

피연산자를 비트로 바꿨을 때 각각 대응하는 비트가 모두 1이거나 한 쪽이 1이면 1을 반환.

console.log(3 | 5) // 011 & 101 = 7
console.log(3 | 2) // 11 & 10 = 3

^ (XOR)

피연산자를 비트로 바꿨을 때 대응하는 비트가 서로 다르면 1을 반환.

console.log(3 ^ 5) // 011 ^ 101 = 6
console.log(3 ^ 2) // 11 ^ 10 = 1

~ (NOT)

피연산자의 반전된 값을 반환.

console.log(~-1) // 0
console.log(~3) // -4
console.log(~-5) // 4

\<\< (부호 유지 왼쪽 시프트)

피연산자를 비트로 바꿨을 때 비트들을 값만큼 왼쪽으로 이동.

console.log(4 << 1) // 8
console.log(4 << 2) // 16
console.log(-4 << 2) // -16

>> (부호 유지 오른쪽 시프트)

피연산자를 비트로 바꿨을 때 비트들을 값만큼 오른쪽으로 이동.

console.log(4 >> 1) // 2
console.log(4 >> 2) // 1
console.log(-4 >> 2) // -1

>>> (부호 버림 오른쪽 시프트)

피연산자를 비트로 바꿨을 때 비트들을 값만큼 오른쪽으로 이동.

console.log(4 >>> 1) // 2
console.log(-1 >>> 1) // 2147483647
PreviousProcess vs ThreadNext그레이 코드

Last updated 5 years ago

Was this helpful?