728x90
728x170
*[STL] bitset
- 문자를 2진수로 바꿔주는 함수.
- 템플릿
template <size_t N> class bitset;
- 자세한 내용 : http://www.cplusplus.com/reference/bitset/bitset/?kw=bitset
[예제 코드]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 |
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
char a = 2;
int b = 16;
double c = 64;
// bitset<size>(variable) => size : 자릿수, variable : 변수
cout << "a = " << bitset<8>(a) << endl; // 00000010
cout << "b = " << bitset<32>(a) << endl; // 00000000000000000000000000010000
cout << "c = " << bitset<64>(a) << endl; // 0000000000000000000000000000000000000000000000000000000001000000
return 0;
} |
cs |
728x90
그리드형(광고전용)
'Programming > C++' 카테고리의 다른 글
[header][container] map (0) | 2017.11.08 |
---|---|
[header][container] array (C++11) (0) | 2017.11.08 |
[header][container] vector (0) | 2017.11.08 |
[STL] binary_search (0) | 2017.11.08 |
[STL] sprintf (0) | 2017.10.21 |
[STL] getline (0) | 2017.10.20 |
[STL] ceil, floor, round (0) | 2017.09.23 |
[STL] sort (0) | 2017.09.22 |