-
pls help me!!
pls anyone who is kind enough to help on my problem about a certain program of mine about converting binary to decimal pls help me im begging to someone who read this pls .
helpPPPPPPPPPPPPPPPP helpppppppppppppppppp
help help help help help help help!!!!!!!!
-
UM....One way is to have each binary number inputed to an int(or bool) array, then have the program see which array elements are set(1) and add those together. EX:
user enters 100110
You assign each value to a int[] element and then just say:
for(i=0; i<sizeof(intarray); i++){
if(intarray[i] == 1) {
intarray[i] = pow(2, i); //reasign the array element for
// the decimal number to conserve memory.
}
Then addup all the intarray values and you will have a decimal number. I think this method will work, but I didn't try it.