Basic CS help PLZ (binary Numbers)

<p>this is pretty basic and in my intro to CS class, but im not sure im doing it right…</p>

<p>cover the following binary Numbers
345
i got
0101011001</p>

<p>23.125
i got
0000010111001</p>

<p>can someone conform my results or tell me im wrong</p>

<p>thanks</p>

<p>First one’s correct, I’m assuming the leading 0 is the sign bit for twos complement.</p>

<p>Second one has the right bits, but a) you forgot the binary point, and b) I don’t know why you need more than 1 leading zero, assuming you’re doing two’s complement. </p>

<p>I would have said 010111.001</p>

<p>Of course you may be learning something another way that I’m not familiar with.</p>

<p>345/2 = 172 r 1
172/2 = 86 r 0
86/2 = 43 r 0
43/2 = 21 r 1
21/2 = 10 r 1
10/2 = 5 r 0
5/2 = 2 r 1
2/2 = 1 r 0
1/2 = 0 r 1</p>

<p>answer: 101011001</p>

<p>23/2 = 11 r 1
11/2 = 5 r 1
5/2 = 2 r 1
2/2 = 1 r 0
1/2 = 0 r 1</p>

<p>.125 * 2 = 0.25
0.25<em>2 = 0.5
0.5</em>2 = 1</p>

<p>answer: 10111.001</p>

<p>BTW, I don’t think this post best suits the interest of this board.</p>

<p>lol…</p>

<p>i think im being taught a different way than you guys…</p>

<p>BTW, I don’t think this post best suits the interest of this board.</p>

<p>btw, i dont care</p>

<p>but thanks rockerdad and sang</p>

<p>sang54 - you are correct if you’re working with unsigned, otherwise if you’re working in twos complement, your numbers are negative.</p>

<p>sdmatt, can you explain how are you being taught?</p>

<p>As far as whether it’s appropriate, it’s not like sdmatt didn’t do the work or didn’t understand, he just had a few basic questions about binary points and leading zeros and is using a really simple problem to ask the questions. It’s like 3rd grade stuff if you are raised speaking decimal instead of binary.</p>

<p>heres how i was taught to do it</p>

<p>345</p>

<p>2^0=1 /1
2^1=2 /0
2^2=4 /0
2^3=8 /1
2^4=16 /1
2^5=32 /0
2^6=64 /1
2^7=128 /0
2^8=256 /1
2^9=512 /0</p>

<p>start at the bottom , but a zero next to it if it does not apply</p>

<p>345-256=89
89-64=25
25-16=9
9-8=1</p>

<p>so, 0101011001 ?</p>

<p>Are you doing twos complement or unsigned.</p>

<p>Why do you start with 2^9 instead of 2^8? If it were unsigned, would you write 0345 in decimal? What you have isn’t wrong, I’m just trying to understand your reasoning about where you start.</p>

<p>How did you do 23.125?</p>

<p>i think i figured it out now… i was lost earlier … but used some common sense.</p>

<p>2^-3=.125/1
2^-2=.25/0
2^-1=.5/0
2^0=1 /1
2^1=2 /1
2^2=4 /1
2^3=8 /0
2^4=16/ 1</p>

<p>so 23.125= 10111.001</p>

<p>i didnt realize all those zeros were unnecessay</p>

<p>They may be necessary depending on whether your representation is unsigned, in which case you’re fine, or is twos complement in which case you need a leading zero to indicate that it’s positive. </p>

<p>In twos complement, what you wrote 10111.001 would be -01000.111 = 8.875,
so if you’re working with twos complement (most common), you need one leading zero.</p>