Binary / Machine Language

mayorredbeard

Daemon Poster
Messages
1,246
With the amount of computer geeks on here (including myself) someone should be able to help me :p. Im trying to understand processors to its full extent. And i'm starting out by getting an understanding of binary, how it works, and how you use it.

I can count in binary (check me out)
[quote="me counting in binary :-D]
0 - 0
1 - 1
2 - 10
3 - 11
4 - 100
5 - 101
6 - 110
7 - 111
8 - 1000
9 - 1001
10 - 1010
[/quote]

Anyways is their a trick to using your logic to determine the binary value of a random decimal number? Like if I were doing addition, and added these to binary numbers "1001 [9]" to "1000 [8]" which i know is 17, is their anyway of manually finding out what the binary equivalent of 17 is without counting all the way up to 17 in binary?
 
yeah there is a way but it's not exactly as mathematical as you might think. This is the method that I use. To convert a number like 17 to binary you need to divide by 2 until you reach 0 and take note of whether or not 2 divides in evenly (is there a remainder or not?). Here is how it is done:

17/2 = 8 R(remainder)1
8/2 = 4 R 0
4/2 = 2 R 0
2/2 = 1 R 0
1/2 = 0 R 1 --> and this is where you would stop dividing because you get a zero

You then take all remainders starting from the last one and writing them down backwards to get '10001'.

And here's 100 for another example:

100/2 = 50 R 0
50/2 = 25 R 0
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

And you get '1100100'
 
wow, thats ingenuis. did you think of that yourself? or did you get that from a website? haha i've been playing around with that looking for exceptions but it seem to work. thanks for the neat trick.

EDIT:

wait... if i wanted to convert to say, o iunno, base 3 system, would i just divide by 3 and use the same trick with the remainders? seems to work right?

does anyone know any tricks for multiplying, or dividing binary numbers?
 
naw, i didnt think of it myself although it would have been impressive to say that i did! That's something i've learned in university (yes i learned something!). I'm a second year computer science major.
If I can remember correctly there may be a different approach needed to use different bases (unless you say you've got the base 3 working the same way). However using, say, hexadecimal requires a little bit of a modified version (which of course I can't remember at the moment but i can dig it up if you want).

I think to multiply and divide would be much easier to just convert the binary to base 10 and do it like normal then convert back to binary because I can't think of a simple way to do it differently.
 
wow a computer science major? i dont know how much you know about processors, and their architechture in particular. I'm not sure if your computer science courses cover hardware, but if any of your books you have have any diagrams of a detailed architechture of any aspect of an actual processor that would be cool. not just the black-boxes, but a small portion of the blueprints of the actual gates and transistors on the processor. i've started a new thread on the subject in the processors section so if you know anything please post their!
 
mayorredbeard said:
wow a computer science major? i dont know how much you know about processors, and their architechture in particular. I'm not sure if your computer science courses cover hardware, but if any of your books you have have any diagrams of a detailed architechture of any aspect of an actual processor that would be cool. not just the black-boxes, but a small portion of the blueprints of the actual gates and transistors on the processor. i've started a new thread on the subject in the processors section so if you know anything please post their!

Well, i will be able to help you....but that is of course the future tense. I have a course called Computer Architecture that I will be taking but it won't be until my second semester (which will not be until next year). I think that will cover what you are asking about but as you have already figured out im sure, I cant help you on that yet. I've only officially completed one year of university so my knowledge is still quite insufficient on the subject. :p
 
Kuberr said:
Uh, can't you add the binary digits together?

1001
+1000
_____
10001

yes, there is a little bit more to know about adding and subtracting in binary but what you've got there is correct.
 
peforming mathematical operations in binary itself seems kind of silly, much easier just to convert using these lil tricks and do it in our decimal system.

is their a trick for going from binary to decimal? i tried doing your trick backwards, but that doesnt really work out :p
 
Back
Top Bottom