English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-10-24 17:09:36 · 5 answers · asked by yeahuhword 1 in Education & Reference Homework Help

5 answers

Converting from Base 10 to Base 2

Usually the base ten number is entered into a text field and is represented as a string of characters.
Each string character is then moved to a struct for a base 10 number.
Regroup the digits into a string of 6 digits and convert them to a long integer.
Convert this array of long to base 256. 256 is a base that is a power of 2 and the divide procedures for changing base is sped up by using a larger base.
The base 256 remainders are placed in an array becoming the base 256 number.
An array with the known binary strings for each number between 0 to 255 is used to convert base 256 to base 2.
0256 = 000000002, 255256 = 111111112

2006-10-24 17:14:08 · answer #1 · answered by sharrron 5 · 0 2

The first answer is good. Here's an alternate if you don't have the powers of 2 memorized: divide by 2 repeatedly and arrange your "remainders" in reverse order, as follows.

205 / 2 = 102 R 1
102 / 2 = 51 R 0
51 / 2 = 25 R 1
25 / 2 = 12 R 1
12 / 2 = 6 R 0
6 / 2 = 3 R 0
3 / 2 = 1 R 1
1 / 2 = 0 R 1

stringing the remainders in reverse yields:
11001101
Cross-check with the first answer's technique, if necessary (and time allows)

2006-10-24 17:33:34 · answer #2 · answered by John K 4 · 0 0

use repeated division
205 / 2 = 102 Remainder 1
102 / 2 = 51Remainder 0
51 / 2 = 25 Remainder 1
25 / 2 = 12 Remainder 1
12 / 2 = 6 Remainder 0
6 / 2 = 3 R emainde r 0
3 / 2 = 1 Remainder 1
1 / 2 = 0 Remainder 1
then asn= 11001101

2006-10-24 17:41:25 · answer #3 · answered by Sammy 1 · 0 0

here ya go:

11001101

keep in mind that each position of the binary number represents 2 to an exponent: from Left to Right, it's 2 to the 0 power, 1 power, 2 power, etc.

so 205 =

128*1 + 64*1 + 32*0 + 16*0 + 8*1 + 4*1 + 2*0 + 1*1 (base 10) =

11001101 (base 2)

EDITED TO ADD:

Ignore answerer #2 -- you're not gonna have your PC with you on test day, so you need to learn how to do these without aid of computer!

2006-10-24 17:10:54 · answer #4 · answered by djc 3 · 3 0

11001101

If you have Windows, run Calc, click on Scientific, then at the top there's a row of radio buttons marked Hex Dec Oct Bin. Just type your number in Dec, then switch to Bin and it'll automatically convert it for you.

2006-10-24 17:12:16 · answer #5 · answered by supensa 6 · 1 1

fedest.com, questions and answers