반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- React
- BinaryTree
- route
- routes
- MySQL
- nodeJS
- axios
- event
- bit
- node.js
- treenode
- 비트연산
- JSX
- server
- c++
- queue
- Navigation
- css
- Context
- Props
- UE5
- priority_queue
- leetcode
- component
- Callback
- DP
- state
- map
- count
- array
Archives
- Today
- Total
우사미 코딩
[C++] 10진수를 2진수로 출력하는 방법 - bitset 본문
반응형
10진수의 정수를 bit로 출력하기 위해서는 아래와 같이 bitset 클래스를 사용한다.
#include<bitset>
- 코드
#include<bitset>
int main() {
int n = 32;
cout << "n : " << n << endl;
cout << "bit(8) : " << bitset<8>(n) << endl;
cout << "bit(32) : " << bitset<32>(n) << endl;
return 0;
}
- 출력
n : 32
bit(8) : 00100000
bit(32) : 00000000000000000000000000100000반응형
'Programming (C++) > C++' 카테고리의 다른 글
| [C++] 알파벳 a-z ↔ 0-26 변환하는 방법 (int ↔ char) (0) | 2023.05.21 |
|---|---|
| [C++] ASCII를 사용하여 uppercase <-> lowercase 변환하기 (0) | 2023.05.21 |
| [C++ / istringstream] string 문자열을 공백문자를 기준으로 나누기 (0) | 2023.04.28 |
Comments