int num = 5;
for (int pow = 1;;){
// check for max power coefficient
pow <<= 1;
if (pow <= num ) continue;
int binary = 0;
binary:
// count down from highest power
pow >>= 1;
if (pow >= 1 ) {
int bit = (((num-pow)<0) ? 0 : 1);
if (bit == 1) num -= pow;
binary = (binary*10) + bit;
goto binary;
}
num = binary;
break;
}
cout << dec << "[0B" << num << ']' << endl;