convert binary to decimal than this?
int binary_to_decimal(int binary)
{
int decimal = 0, base = 1;
while (binary)
decimal += (binary % 10) * base, binary /= 10, base *= 2;
return decimal;
}
a shorter way to convert binary to decimal is this : std::cout << std::dec << 0b101; In case you don't want to implement the function yourself
Are you sure this is a function that converts given binary to decimal?
Yep, you can google stream manipulators
Обсуждают сегодня