How to convert binary representation into a number in C++

1 Answer

0 votes
#include <iostream>
#include <bitset>

using std::cout;
using std::endl;

int main()
{
	cout << "\"100110101\" : " << std::bitset<100>(std::string("100110101")).to_ulong() << endl;
}

/*
run:

"100110101" : 309

*/

 



answered Feb 23, 2018 by avibootz
...