>>fromBinaryToDecimal
To convert from binary to decimal you use the expansion rule.
For example : convert "1010" to its decimal value.
To convert 1010 into a decimal value, we note the position of each bit.
3 2 1 0 //position of each bit
1 0 1 0 //binary number
Now we use the general expansion rule:
To convert from binary to decimal the general rule is: a0 * 2^x + a1* 2^(x-1) ...
ax * 2^0, there "^" represent the power function, and x represent the bits position, and ax is the bits coefficient at its position.
So to convert 1010 to decimal we do:
1*2^3 + 0*2^2 + 1*2^1 + 0*2^0
1*8 + 0*4 + 1*2 + 0*1
8 + 0 + 2 + 0 = 10
Thus the binary number 1010 in decimal base is 10.
Now turn that math into C++ code.