- binary to decimal
- bindec
1 C++[ | ]

C++
Copy
#include <iostream>
using namespace std;
int main() {
char bin[] = "110";
int dec = stoi(bin, 0, 2);
cout << dec << endl; // 6
char bin2[] = "1101000";
int dec2 = stoi(bin2, 0, 2);
cout << dec2 << endl; // 104
}
Loading
2 JavaScript[ | ]

JavaScript
Copy
console.log( parseInt("110", 2) ); // 6
console.log( parseInt("1101000", 2) ); // 104
3 PHP[ | ]

PHP
Copy
echo bindec(110);
// 6
echo bindec('110');
// 6
4 Python[ | ]
Python
Copy
print 0b110
# 6
print int('110', 2)
# 6
print int('0b110', 2)
# 6
5 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.