I need some help with my Comp Sci class

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Ok, so today was the first real day of work. He basically went over Binary, converting from "two," to "decimal," to "hex," to "octal."

He wrote this down and told us to continue the rest as we saw it:

0
1
10
11
100
101
110
111

and so fourth and so on.

Now, what in the heck was he writing the above for?

I am kinda lost, but I kinda understand it at the same time. Please tell me what exactly was he trying to do with the above? I think he was trying to explain that that is binary for 1, 2, 3, 4, 5, 6 and so fourth and so on. But how is it binary for that? I know sometimes you will need to use the power of 2...

HELP?
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
that counts from 0 to 7. the next one would be 1000 and so on

although i dont understand ur question?
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Originally posted by: dighn
that counts from 0 to 7. the next one would be 1000 and so on

although i dont understand ur question?

How do you get the next number for 7, and 8 and 9 and so on? How do you go about finding out the number in binary?
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
oh ic

the hard way would be to use convert using powers of two

but if you are just counting
0
1
10
11
100

etc

just add 1 to the least significant figure, whenever you have more than 1 in a place, subtract two and carry it over to the next more signiifcant place. just like decimal 10 counting except you carry when u get a 2 or more

after you do this for a while you won't even think about it. it'll be as natural as counting in decimal. probably easier too
 

Deeko

Lifer
Jun 16, 2000
30,213
12
81
Basically...think how we number things in base 10. You have 0-9, then the next column, which is 0-9 + 10, then 0-9 + 100, and so forth. Binary is the same way, except it is base 2, so it is 0-1, 0-1 + 2, 0-1 + 4, and so on.

1
01
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1111

and so on..
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Originally posted by: dighn
oh ic

the hard way would be to use convert using powers of two

but if you are just counting
0
1
10
11
100

etc

just add 1 to the least significant figure, whenever you have more than 1 in a place, subtract two and carry it over to the next more signiifcant place. just like decimal 10 counting except you carry when u get a 2 or more

after you do this for a while you won't even think about it. it'll be as natural as counting in decimal. probably easier too

Yes, my teacher wants us to use the power of 2. Thanks for all the answers, I truly appreciate it.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Think about decimal, what happens counting up when you reach 9, or 99, or 999? You add an extra digit that you know is multiplied by 10 or some power of 10.

19 = (1 x 10) + (9 x 1) = (1 x 10^1) + (9 x 10^0)

in binary

11 = (1 x 2) + (1 x 1) = (1 x 2^1) + (1 x 2^0)
100 = (1 x 4) + (0 x 2) + (0 x 1) = (1 x 2^2) + . . .

ever hear the term "byte"? It's usually 8 "bits" (binary digits) or something like
10001001 (= 137 decimal)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111


It's just counting, except you add a new digit after 1 instead of after 9.
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Ok, I need to change a base 2 number into a decimal. I already did the formula and what not. I multiplied each 1 and 0 in the number by 1, then 2, then 2^2, then 2^3 so fourth and so on. I added up the numbers, and how do I turn it into a decimal?

1100100101 is the base 2 number I need to convert it into a decimal, a hexadecimal, and a octal.

Added up altogether the number from the base two through my own calculations came out to: 805.

Does or did your Comp Sci teacher let you use a calculator for any of this? My teach said NO calculator.

I'm sorry 805 is the decimal number. I'm an idiot, forgive me.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: Nocturnal
Ok, I need to change a base 2 number into a decimal. I already did the formula and what not. I multiplied each 1 and 0 in the number by 1, then 2, then 2^2, then 2^3 so fourth and so on. I added up the numbers, and how do I turn it into a decimal?

1100100101 is the base 2 number I need to convert it into a decimal, a hexadecimal, and a octal.

Added up altogether the number from the base two through my own calculations came out to: 805.

Does or did your Comp Sci teacher let you use a calculator for any of this? My teach said NO calculator.

As a Computer engineering student, My lecturer required me to remember 2^0 to 2^N where N can be 10 or more. You'll get it along with time. Do you know how to convert Bin to decimal??
 

Deeko

Lifer
Jun 16, 2000
30,213
12
81
805 looks good. Dude, I don't even get a calculutor in Calculus, let alone comp sci.
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Originally posted by: pillage2001
Originally posted by: Nocturnal
Ok, I need to change a base 2 number into a decimal. I already did the formula and what not. I multiplied each 1 and 0 in the number by 1, then 2, then 2^2, then 2^3 so fourth and so on. I added up the numbers, and how do I turn it into a decimal?

1100100101 is the base 2 number I need to convert it into a decimal, a hexadecimal, and a octal.

Added up altogether the number from the base two through my own calculations came out to: 805.

Does or did your Comp Sci teacher let you use a calculator for any of this? My teach said NO calculator.

As a Computer engineering student, My lecturer required me to remember 2^0 to 2^N where N can be 10 or more. You'll get it along with time. Do you know how to convert Bin to decimal??

Yeah the above number was a binary number and I just converted it to decimal.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: Nocturnal
Ok, I need to change a base 2 number into a decimal. I already did the formula and what not. I multiplied each 1 and 0 in the number by 1, then 2, then 2^2, then 2^3 so fourth and so on. I added up the numbers, and how do I turn it into a decimal?

1100100101 is the base 2 number I need to convert it into a decimal, a hexadecimal, and a octal.

Added up altogether the number from the base two through my own calculations came out to: 805.

Does or did your Comp Sci teacher let you use a calculator for any of this? My teach said NO calculator.

well if you add up the numbers then u already converted it to decimal LOL


as for hex decimal, just divide the bin into sections of 4 bits and convert each to hex. for oct, 3 bit sections and the same

u dont need a calculate for this, even if you have to convert decimal <-->bin.

edit: 805 is right
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Now I have questions regarding turning a decimal into a Hexadecimal. He went over it SO quickly that I was like WTF! Can anyone explain the list on how it goes from 1-7?????????
 

Deeko

Lifer
Jun 16, 2000
30,213
12
81
Originally posted by: charrison
there are 10 types of people in the world, those that understand binary and those that dont;)

oldest geek joke EVER
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
16^n
n 0 to whatever

but if you are just converting binary to hex, just convert sections of 4 bits individually eg 10101011 would be 6B 6 for 1010 B for 1011
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
Originally posted by: charrison
there are 10 types of people in the world, those that understand binary and those that dont;)

It's actually my first Computer Science class, EVER. Never had any previous exprience with binary numbers or converting them for that matter. So, I'm a first day student you could say. I hope to improve with time.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: Nocturnal
Ok, I need to change a base 2 number into a decimal. I already did the formula and what not. I multiplied each 1 and 0 in the number by 1, then 2, then 2^2, then 2^3 so fourth and so on. I added up the numbers, and how do I turn it into a decimal?

1100100101 is the base 2 number I need to convert it into a decimal, a hexadecimal, and a octal.
Added up altogether the number from the base two through my own calculations came out to: 805.
Does or did your Comp Sci teacher let you use a calculator for any of this? My teach said NO calculator.
I'm sorry 805 is the decimal number. I'm an idiot, forgive me.

1 x 1 = 1
0 x 2 = 0
1 x 4 = 4
0 x 8 = 0
0 x 16 = 0
1 x 32 = 32
0 x 64 = 0
0 x 128 = 0
1 x 256 = 256
1 x 512 = 512

1 + 4 + 32 + 256 + 512 = 805

There is absolutely no point to doing this on a calculator. The whole point is to understand how different number systems relate to each other. The reason teachers allow you to use calculators is to ease computation while still studying the concept. If you don't do the computations here, you completely miss the concept.

It's really easy.
 

charrison

Lifer
Oct 13, 1999
17,033
1
81
Originally posted by: Nocturnal
Originally posted by: charrison
there are 10 types of people in the world, those that understand binary and those that dont;)

It's actually my first Computer Science class, EVER. Never had any previous exprience with binary numbers or converting them for that matter. So, I'm a first day student you could say. I hope to improve with time.

Most people never have to deal with them :) Fortunatly this stuff is pretty easy.
 

Nocturnal

Lifer
Jan 8, 2002
18,927
0
76
I totally get the binary to decimal right now. But going from decimal to hex, and then from hex to octal I do not fully understand. My teacher was RUSHING big time towards the end of class and he then asked if we had any questions and right before I was about to go up and talk to him he rushed out the door in order to give out cd-rs with the newest Java SDK on it to students.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: Nocturnal
I totally get the binary to decimal right now. But going from decimal to hex, and then from hex to octal I do not fully understand. My teacher was RUSHING big time towards the end of class and he then asked if we had any questions and right before I was about to go up and talk to him he rushed out the door in order to give out cd-rs with the newest Java SDK on it to students.

LOL

anyway
conversions between bin, hex and oct are really easy, see my posts above

as for decimal to hex use the same kind of conversion process as binary