Jump to content
  • Advertisement
Sign in to follow this  
MitchellH

Learn and practice binary and hexadecimal numbers

This topic is 4948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Over my years of learning programming, ive learned that binary and hexadecimal numbers are very important. I have learned each maybe once or twice but not enough to truly remember them. I am looking for a quality tutorial that you would recommend as a way to learn and practice binary/hex numbers. Thank you :)

Share this post


Link to post
Share on other sites
Advertisement
They work the same way "normal" base 10 numbers work.

If you want to set a given bit, use the left shift operator, and shift 1 to the left enough times, using bitwise or to set more than one bit.

To convert from decimal to dex or binary, use the windows calculator (or, alternatively, create your own small program... base changing is extremely easy).

Share this post


Link to post
Share on other sites
Do you basically understand how they work?

There's no question of practicing them. They come up useful in a lot of situations, and after encountering those situations over and over, you just get used to them.

One useful thing to know -- every hex digit is 4 binary digits. This makes converting from hex to binary very easy/

Share this post


Link to post
Share on other sites
It's been a couple of years since I've done this, so I might be a little off, but to do it by hand you need to use the Euclidian algorithm. I'm sure if mathworld or a similar math website could show you the inner workings of the algorithm.

Share this post


Link to post
Share on other sites
As a sidenote, today in class I was doing a history assignment for "Chaper 11" and thought, we just did chapter ten, why are we going back to three? Then I laughed at myself and only I knew what was so funny.

Anyway, to actually kind of contribute, knowing them comes in handy. Understanding how they represent the underlying data is vital. Its good to understand that the system we count with is similar to words in that, no matter you call them, they still represent the same thing. When you are dealing with data in RAM for example, four bytes could hold 0xBAADF00D, 3131961357, or 1011 1010 1010 1101 1111 0000 0000 1101 . Those charactors are simply a system that is used to represent the data that is there.

Hopefully that made some sence... I think I tried to get way to deep just then...

Dwiel

Share this post


Link to post
Share on other sites
Quote:
Original post by Tazzel3D
As a sidenote, today in class I was doing a history assignment for "Chaper 11" and thought, we just did chapter ten, why are we going back to three? Then I laughed at myself and only I knew what was so funny.


Nerd!! Just kidding [grin] I think that's funny as well.

Share this post


Link to post
Share on other sites

8-bit binary number: 11010101
||||||||
27 (128) -+|||||||
26 (64) --+||||||
25 (32) ---+|||||
24 (16) ----+||||
23 (8) -----+|||
22 (4) ------+||
21 (2) -------+|
20 (1) --------+

decimal number: 128 + 64 + 16 + 4 + 1 = 213
It's not difficult to convert binary to decimal at all, and after a while you can do it in your head.

Every 4-bit group represents 1 hex digit.

0000 - 0
0001 - 1
0010 - 2
0011 - 3
0100 - 4
0101 - 5
0110 - 6
0111 - 7
1000 - 8
1001 - 9
1010 - A (10)
1011 - B (11)
1100 - C (12)
1101 - D (13)
1110 - E (14)
1111 - F (15)
So in the binary -> decimal example, 11010101, or 213, would be D5 in hex.

Share this post


Link to post
Share on other sites
I have binary numbers down pretty good now. I read John Selvia's tutorials on counting binary numbers on your fingers and it helps a lot in converting back and forth very quickly :) (but only up to 1023)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!