Asrarahmed Kadri wrote: > Can anyone help me with teh problem of "converting a decimal number > into its binary equivalent"?? > Ah, sorry, I didn't read the subject line, just the e-mail. You said a decimal integer into binary. I thought you meant any random decimal value. My bad :) You should be able to find a tutorial on this on-line somewhere.
you know that decimal: 1 = binary: 0001 decimal: 2 = binary: 0010 decimal: 4 = binary: 0100 decimal: 8 = binary: 1000 Do you see the pattern here? It's powers of 2. I don't have time to write an example program, but see what you can do. Basically, if I remember correctly, you have to find the smallest power of 2 that is greater than your number, then repeatedly divide then mod the integer for each binary digit. > Thanks in anticipation. sure. > > Regards, > Asrar Kadri -Luke _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor