News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

### Author Topic: Decimal to Binary Help  (Read 2331 times)

#### SomeNoob

• Newbie
• Posts: 1
##### Decimal to Binary Help
« on: June 26, 2015, 01:43:14 pm »
I'm somewhat hesitant to post this due to the fact most of the other problems in other posts are more advanced than what I'm having trouble with.

As a person who had just been introduced into the world of rom hacking, I am currently on the basics, learning hexadecimal, decimal, and binary conversions. After reading Neil_'s "The Basics of Bases," I decided to practicing converting base ten numbers into binary and hexadecimal by generating random numbers to convert into binary and hexadecimal.

My first number I practiced on, 283, I converted into 100011011, using Neil_'s way of showing work.

283/2 is 141 r 1
141/2 is 70 r 1
70/2 is 35 r 0
35/2 is 17 r 1
17/2 is 8 r 1
8/2 is 4 r 0
4/2 is 2 r 0
2/2 is 1 r 0
1/2 is 0 r 1
Thus, I converted 283 in binary. Upon checking this on a decimal to binary website, I found that they converted 283 to be 0000000100011011, with 7 more 0's ahead of the answer I found. I checked my work many times, cross-checked the answers with other websites converting decimal to binary, but I could not figure out what I had missed. Perhaps I don't have a certain concept down?

I hope that this is the right board I am posting in, as I could not find any other categories that dealt with newcomers like me. If I posted in the wrong section of the forums, I sincerely apologize.

#### Disch

• Hero Member
• Posts: 2814
• NES Junkie
##### Re: Decimal to Binary Help
« Reply #1 on: June 26, 2015, 01:53:13 pm »
Quote

They're both the same number.

15  and 000000015 are both "fifteen", it doesn't matter how many zeros you throw in front of it.

PS:  Never apologize for posting a question on a forum designed for posting questions

EDIT:

The reason it posted more zeros is because hex/bin numbers are usually byte-aligned since that's usually what they represent.

So binary numbers are typically grouped into 8 digits -- or multiples of 8
And hex numbers are typically grouped into 2 digits -- or multiples of 2

Since 1 byte = 8 bin digits or 2 hex digits.

#### C_CliFF

• Jr. Member
• Posts: 64
##### Re: Decimal to Binary Help
« Reply #2 on: June 26, 2015, 01:58:16 pm »
If you want to learn this I would recommend using this tutorial instead:

http://www.smstributes.co.uk/view_article.asp?articleid=40

It's the first three sections. It explains much more in detail (and also the tutorial I used to be more confident in binary and hex).

#### Disch

• Hero Member
• Posts: 2814
• NES Junkie
##### Re: Decimal to Binary Help
« Reply #3 on: June 26, 2015, 02:06:05 pm »
FWIW:

I'd argue that learning how to manually convert bin<->dec or hex<->dec is largely a waste of time.  It's much more valuable to be able to manually convert hex<->bin (and it's much easier since their relationship is closer)

For conversions to/from dec... just use a calculator.  If you're on Windows, you can use calc.exe... switch the view to Programmer.  Once there you can select a base with radio buttons (Hex/Dec/Oct/Bin)... input a number, then just switch to another base and it'll do the conversion.

The only thing that's really useful to remember with dec is the below:

Code: [Select]
`bin        hex   dec--------------------00000001 = 01  =   100000010 = 02  =   200000100 = 04  =   400001000 = 08  =   800010000 = 10  =  1600100000 = 20  =  3201000000 = 40  =  6410000000 = 80  = 128`
So really... if you can memorize your powers-of-2 up to 8 places, you'll be fine.

#### Seihen

• Sr. Member
• Posts: 404
##### Re: Decimal to Binary Help
« Reply #4 on: June 27, 2015, 03:03:13 am »
Or open up excel and type =dec2bin(YOURNUMBERHERE). Hell, you can even do dec2hex.

Or just make a simple calculator that way. Saves you the time of having to click between modes on calc.exe

#### Dr. Floppy

• Restricted Access
• Hero Member
• Posts: 970
• Make America GREAT Again!
##### Re: Decimal to Binary Help
« Reply #5 on: July 05, 2015, 04:19:03 pm »
A few dopey mnemonics that helped me out back in the day:

\$0 = 0000  Easy!
\$1 = 0001  Also easy.

\$4 = 0100

\$6 = 0110 --> Sorta looks like "OTTO" --> Germanic name --> Nazis --> Evil --> Six

\$A = 1010 --> "A" is ten in hex, and the binary reads "ten-ten".

\$B = 1011 ==_\
\$D = 1101 ==>  I always likened the binary representations to the lower-case "letter" forms. 'b' has its bulk to the right, while 'd' carries its bulk to the left.

\$F = 1111  Maxed-out; highest value by default.

#### BlackDog61

• Hero Member
• Posts: 784
##### Re: Decimal to Binary Help
« Reply #6 on: July 05, 2015, 05:29:27 pm »
I think taking timeto run your brain around how these things work is a worthy effort.
Once you're very familiar with hex & bin,you don't notice them as stranger anymore.
If the author is taking this as an exercise to see hex & bin in practice, I applaud and encourage to keep going. Like other said, in the future tools will do it for you in practice. But understanding what binary & hex arithmetics do to numbers is a good idea.