To dig deep about comp. engineering we need to have a good fundamental on computer arithmetic.
One of the the fundamental is performing arithmetic operation on numbers, but it’s not “just numbers” that I’d like to review today. It’s unusual number, as I might say.
Ok…there are a number of different bases, or radices. Most of us use the decimal positional numeral system, i.e. base 10 (decimal) for our everyday jobs. When it comes to computers most people use the binary, the hexadecimal or even the octal numeral system (you need to read, Why it’s easier for computer use binary instead of decimal like human). However, there are a number of different “unusual” bases.
For example, there are negative bases. An example is the negadecimal positional numeral system, that is using the base -10. Converting a number from base -10 to base 10 is as simple as:
But why use such a base? It’s very simple, you can represent any number you want, positive or negative, without using a sign. For example:
The conversion from decimal to negadecimal is pretty simple. You continuously divide by -10 and keep the remainder as you would do with any other positional numeral system. For example:
So . Converting a positive number is done the same way too.
So . As you can see, there is no need for a sign symbol (pretty neat huh?). And when using the negabinary numeral system there is no problem with signed and unsigned integers since there is no need for a sign bit!
But a negative base isn’t the only non-standard base. You can use complex numbers as bases too. This way there is no need to use a real and an imaginary part to represent a complex number. An example of such a base is where of course . A number can then have the form
Using this base you can represent any complex you want without using the symbol (God bless the inventor of this technique).
Converting from this base to decimal is pretty simple, however the reverse is a little bit difficult. What you do for the convertion is divide continuously with as usual. The remainder will always be or . So, if the quotient is then:
That means that if and are both odd or even, then , otherwise . Then we continue the division of the quotient as usual.
Now let’s calculate the value of 2.
2 has both the real and imaginary part even, so .
The real and imaginary part are both odd, so again.
Since the real part is even and the imaginary is odd, . So, we can divide by the number minus 1 and the remainder will be 0.
Now, the real part is odd and the imaginary is even. So again . We divide by so,
We now stop since . So we have . Pretty cool, now anyone can code it on NetBeans!
That’s something that I dig deep on the library of engineering at UDE for the last few weeks…hehehe….geeks die hard!
Finally on Monday, I went to the front of Prof. Auer’s Comp. Arithmetic class and solve some problems on the board and voila got bonus point as well.
~Semangat Anak Medan.
Studentenwerk, Kammerstrasse 206-208, 47057 Duisburg, Germany.