CM.4 Conversion with out exponentials
A part of a collection on Cybersecurity Math.
Please learn the next posts first except you’re already aware of these ideas:
- Why binary and hexadecimal are used with computer systems.
- Why that issues for cybersecurity.
- The connection between binary, decimal, and hexadecimal
- Tips on how to rely in binary
- Tips on how to rely in hexadecimal
On this publish I’ll clarify methods to convert bigger binary numbers to decimal and hexadecimal utilizing a trick I discovered off a video. Sadly, I didn’t save the hyperlink. On the time I first discovered this idea I solely discovered one video that confirmed this methodology. Now there are others. It was a form of hyper speaker very excited and speaking about how calculators are unhealthy and never allowed on assessments from someday round 2012 or 2013 or perhaps even previous to that. For those who see a speaker calmly explaining this idea in a video — that’s not the one. 🙂
And, as all the time, I’m including my very own little twist to it with a number of graphics. What we won’t be utilizing, are exponentials. I discover this methodology to be less complicated for my mind to cope with for no matter motive.
Changing binary to decimal
First, we have to assign every digit in our binary quantity a price.
Let’s say we had 5 digits in our binary quantity.
- Begin with one.
- Double the quantity and add the consequence to the left.
- Repeat the final step till you may have the required variety of values.
Now let’s say we need to convert the binary 1010 to decimal.
Repeat the idea above for every digit.
The zero’s are “off” as defined in a previous publish. The one’s are “on”.
Add up the worth of the numbers which are “on.”
That’s it. Now you possibly can convert any binary quantity to decimal.
Let’s attempt a much bigger quantity.
You are able to do this with any size of binary digits. I’ll present you an excellent longer caclulation under.
Convert a binary quantity to hexadecimal
Now let’s say we need to convert the above binary quantity to hexadecimal.
Right here’s the essential level:
Every 4 binary digits in a binary quantity represents one hexadecimal digit.
As I defined earlier than the scale of every binary digit is one bit, so the scale of a hexadecimal quantity is 4 bits.
Recall our earlier chart that I really useful you may need to memorize:
Now lets translate this hexadecimal worth to binary: AE06
When you have memorized this chart as I really useful it will be simple to jot down out the 4 digits for every hexadecimal quantity like this:
Be aware that I dropped the main 0’s within the center column above. Pad every binary quantity with zeros so it turns into a 4 bit quantity. In different phrases, 0 = 0000 and 110 = 0110.
To give you a binary quantity, I merely changed every digit in AE06 with the corresponding binary digits within the picture above.
For those who haven’t memorized the numbers above and also you don’t have a chart helpful, you possibly can look them up in a chart or calculate them utilizing the strategies I confirmed within the prior two posts.
Now let’s say you need to know the decimal worth of AE06.
Now that we all know the binary quantity, you need to use the strategy I confirmed you on the high of the publish to calculate the decimal worth. Work out the worth of every place of your binary quantity. Add up the values the place the digit is “on” or 1.
You possibly can test your work utilizing an internet conversion website just like the one included in my prior posts, or a calculator that can do the conversion for you. On a Mac test your work by typing the quantity into the calculator:
Then select programmer from the view menu.
Woot! Our price matches.
This methodology may get cumbersome for very massive numbers however I presume at that time you doubtless have a calculator accessible to you or some kind of programming language to hurry up the method. Nevertheless it works properly for many smaller hexadecimal values akin to these generally present in community packet headers, for instance. It additionally works if it is advisable to validate {that a} program is correctly changing values from hexadecimal to binary to decimal.
Observe for updates.
Teri Radichel | © 2nd Sight Lab 2023
Like this story? Present your help so I can write extra!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Clap for this story or refer others to observe me.
Observe on Medium: Teri Radichel
Enroll for E mail Record: Teri Radichel
Observe on Twitter: @teriradichel
Observe on Mastodon: @teriradichel@infosec.trade
Observe on Put up: @teriradichel
Observe or Like on Fb: 2nd Sight Lab
Observe or like on YouTube: @2ndsightlab
Purchase a E-book: Teri Radichel on Amazon
Purchase me a espresso: Teri Radichel
Request a penetration take a look at, safety evaluation, or coaching
through LinkedIn: Teri Radichel
Schedule a consulting name with me by way of IANS Analysis
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
Slideshare: Shows by Teri Radichel
Speakerdeck: Shows by Teri Radichel
Recognition: SANS Distinction Makers Award, AWS Hero, IANS School
Certifications: SANS
Training: BA Enterprise, Grasp of Sofware Engineering, Grasp of Infosec
How I obtained into safety: Girl in tech
Firm ~ Cloud Penetration Assessments, Assessments, Coaching ~ 2nd Sight Lab
Cybersecurity for Executives within the Age of Cloud on Amazon