일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
- self driving car
- 백준
- OSQP
- CPP
- PathPlanning
- Recursion
- Leetcode
- 선형대수
- solver
- C++
- Dubins Path
- autonomous vehicle
- 정적라이브러리
- Hybrid A star
- Frenet Coordinate
- Motion Planning
- 경로생성
- 소프티어
- 동적라이브러리
- Graph Neural Network
- DynamicProgramming
- GIT
- GNN
- C
- 공유라이브러리
- 강화학습
- CUDA
- MDP
- 수치최적화
- path planning
- Today
- Total
Swimmer
Bitwise Operation, Operator (비트연산) 본문
Reference : https://en.wikipedia.org/wiki/Bitwise_operation
Bitwise operation is fast and simple action. because it is directly supported by the processor.
On low-cost processors, bitwise operations are substantially faster than division, several times faster than multiplication, somtimes significantly faster than addition. (really??)
- Bitwise Operator
NOT(bitwise complement)
NOT 0111 -> 1000, NOT10101011 -> 01010100
AND ( & )
AND 0101 - 0011 -> 0001, AND0011 - 0010 -> 0010
OR ( | )
OR 0101 - 0011 -> 0111, OR 0010 - 1000 -> 1010
NOT ( ~ )
Not 0101 -> 1010
XOR ( ^ )
XOR 0010 - 1010 -> 1000, XOR 0101 - 0011 -> 0110
XOR 비트 연산의 특징
코딩 문제 중 XOR 비트 연산 관련 문제가 있었는데, 인상 깊은 특징을 발견해 정리 문제 내용은 XOR 비트 연산이 이루어진 Encoding 행렬과 원 행렬의 첫번째 인덱스 값을 입력받았을 때, 원 행렬을
iridescentboy.tistory.com
- Bit shifts
In these operations, the digits are moved (shifted) to the left or right.
In LeetCode, There is problem that bit operator solve problem easily and faster.
class Solution {
public:
bool isPowerOfTwo(int n) {
if(n < 0)
{
return false;
}
else
{
return n && !(n & n-1);
}
}
};
'개념공부 > C, C++' 카테고리의 다른 글
2차원 Vector Sort 방법 (0) | 2023.08.10 |
---|---|
[C언어] 변수의 유효 범위 (variable scope) (0) | 2023.07.03 |
[C++ STL] unordered_map (0) | 2023.01.16 |
[C++ STL] map (0) | 2023.01.16 |
[LeetCode] 1. Two Sum (1) | 2023.01.09 |