-1
$\begingroup$

I am a Computer Science undergraduate and I am currently taking a hardware module that focuses a lot on hardware processors and memory addresses, all of which works in binary. However, the inputs given in the questions are always in hexadecimal, and the methods to compute something are always taught in binary, so it would somewhat require us to constantly switch between binary and hexadecimal back and forth, which I find very tedious and mechanical. Personally I am kind of forced to take a hardware module by my institution, so the only motivation for me to study this module is perhaps the arithmetic beauty behind the computation of other bases, and whether there's a more elegant method out there to make my thinking quicker and sharper. Like how a operation in MIPS involves removing the last 2 digits in binary, which is equivalent to /4 in the hexadecimal representation for most numbers(Pardon if I'm wrong, I'm still relatively new into this concept, that's why for the question).

1)I want to know if there are recommended resources out there to help drill on computational skills on bases other than 10, particularly hexadecimal(Since binary is just operating with 2 numbers and it's just back to square one tedious-ness).

2)Also, please advise me whether it's actually worth it to invest in time to learn how to visualise in hexadecimal well, since there's the other alternative most people are taking to do well in the Mathematical aspect of the module, is to master the conversion from (base 2 to base 10 back and forth), and then (base 2 to base 16 back and forth), which just feels really dry. That being said, I would be quite selective on what I want to learn, like to convert a fairly long decimal number to base 16 directly would require a lot of work since base 16 doesn't come too obvious for me.

Thanks.

$\endgroup$
  • 1
    $\begingroup$ You are thinking too much. If you do work in that area, that skill will develop over time. Converting between hex and bin is just a matter of $4$–bit ungrouping/grouping.The only other base I sometimes saw was octal but this seems to have gone out of fashion. $\endgroup$ – mvw Sep 11 '18 at 10:19
  • $\begingroup$ Yes, the grouping and ungrouping part is just back and forth multiplication/regurgitation of numbers(if the numbers are small and commonly used), but the problem comes when u are shifting bits here and there, using bitwise operators and slotting truncated segments of numbers here and there, want to like get a greater meaning towards these, at least through the quantitive aspect. $\endgroup$ – Prashin Jeevaganth Sep 11 '18 at 10:23
1
$\begingroup$

Converting between binary and hex is straightforward, as hex is simply "chunking" binary digits into groups of 4 i.e. starting from the right, you just replace each group of 4 binary digits with a single hex digit as follows:

$0\text{b}0000 \rightarrow 0\text{x}0$

$0\text{b}0001 \rightarrow 0\text{x}1$

$\dots$

$0\text{b}1110 \rightarrow 0\text{xE}$

$0\text{b}1111 \rightarrow 0\text{xF}$

so, for example,

$0\text{b}1010 \space 0101 \rightarrow 0\text{xA}5$

If you using hex addresses you will soon become familiar with the decimal equivalents of some common addresses e.g.

$0\text{xFF} = 255$

$0\text{x100} = 256$

$0\text{xFFFF} = 65535$

$0\text{x10000} = 65536$

and you will get a "feel" for the magnitude of numbers in hex e.g. $0\text{x}400$ is about $1000$ (to be exact, it is $1024$).

Maybe you will be asked to convert a number between binary, hex and decimal "by hand" in an exam to demonstrate that you understand the principle of different bases. And you might need to know the "ones' complement" representation of negative integers.

But I wouldn't bother learning to do mental arithmetic in hex - that's what calculators are for.

$\endgroup$
  • $\begingroup$ I actually haven't got my hand on a programmable calculator that can help me to change to binary yet, haven't checked out what good models out there and what is allowed in the institute. $\endgroup$ – Prashin Jeevaganth Sep 11 '18 at 10:42
  • $\begingroup$ If you are using Windows then the Windows calculator has a programmer's mode - under the View menu select "Programmer". I imagine there must be a similar utiliity in other OS. $\endgroup$ – gandalf61 Sep 11 '18 at 10:46
  • $\begingroup$ No, I meant like a handheld calculator that does that, I'm quite sure the exam doesn't allow me to use a computer. $\endgroup$ – Prashin Jeevaganth Sep 11 '18 at 10:47
  • 1
    $\begingroup$ I don't think you will be expected to do arithmetic in hex in the exam. As long as you understand the principles of different bases and can convert small numbers from one base to another by hand, that should be sufficient. But if you want to be clear about what might come up in your exam you should ask your teacher/lecturer. $\endgroup$ – gandalf61 Sep 11 '18 at 10:57
  • $\begingroup$ I know that we won't really be expected to convert some large number from decimal to binary etc. What I mean is like if I can do something directly from hexadecimal with some operation that does things in terms of binary, it would be good if I could visualise what is that thing I'm doing in hexadecimal, and compute it in hexadecimal directly without doing any work on paper in binary. $\endgroup$ – Prashin Jeevaganth Sep 11 '18 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.