Bonus Hunter on Computer Arithmetic

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:

d_1d_2d_3d_4\ _{(-10)} = d_1(-10)^3 + d_2(-10)^2 +d_3(-10)^1 + d_4(-10)^0

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:

-1_{(10)} = 1(-10)^1 + 9(-10)^0 = 19_{(-10)}

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:

-256 = 26 * (-10) + 4

26 = -2 * (-10) + 6

-2 = 1 * (-10) + 8

1 = 0 * (-10) + 1

So -256_{10} = 1864_{-10} . Converting a positive number is done the same way too.

256 = -25 * (-10) + 6

-25 = 3 * (-10) + 5

3 = 0 * (-10) + 3

So 256_{(10)} = 356_{(-10)} . 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 -1 + i  where of course i^2 = -1 . A number can then have the form

d_1d_2d_3d_4 = d_1(-1 + i)^3 + d_2(-1 + i)^2 + d_3(-1 + i)^1 + d_4(-1 + i)^0, d_i \in {0,1}

Using this base you can represent any complex you want without using the i 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 -1 + i  as usual. The remainder will always be 0  or 1 . So, if the quotient is q = q_1 + q_2i  then:

a + bi = (q_1 + q_2i)(-1 + i) + r

a + bi = -q_1 + q_1i - q_2i - q_2 + r

a + bi = (-q_1 - q_2 + r) + (q_1 - q_2)i

-q_1 - q_2 + r = a

q_1 - q_2 = b

q_1 = \frac{b - a + r}{2}

q_2 = \frac{-b - a + r}{2}

That means that if a  and b  are both odd or even, then r = 0 , otherwise r = 1 . 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 r = 0 .

\frac{2}{-1 + i} = \frac{2(-1 - i)}{(-1 + i)(-1 - i)} = -1 - i

The real and imaginary part are both odd, so r = 0  again.

\frac{-1 - i}{-1 + i} = \frac{(-1 - i)(-1 - i)}{(-1 + i)(-1 - i)} = i

Since the real part is even and the imaginary is odd, r = 1 . So, we can divide by the number minus 1 and the remainder will be 0.

\frac{i - 1}{-1 + i} = 1

Now, the real part is odd and the imaginary is even. So again r = 1 . We divide by 1 - 1  so,

\frac{1 - 1}{-1 + i} = 0

We now stop since q = 0 . So we have 2_{(10)} = 1100_{(-1 + i)} . 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.


Alright then, that’s all for today lesson.
Keep up the good work.

~Semangat Anak Medan.

Libas!

Studentenwerk, Kammerstrasse 206-208, 47057 Duisburg, Germany.

About these ads

4 Responses to “Bonus Hunter on Computer Arithmetic”

  1. h0tchocolate Says:

    iki ngomongin opo to rek? ora ngerti aku :D semangat to!

  2. kasparovsitumorang Says:

    Itu ngomongin cara buat pecel di German…hehe.
    Masukkan kacang, daun ubi dan cabe secukupnya.
    Jadi deh pecel alsdeutsch.

  3. Okky Says:

    Pake wolfram alpha aja pak… ;))

    • kasparovsitumorang Says:

      Kalo tools sudah banyak Ki, saya pake Matlab, Mathematica dan Wolfram utk memverifikasi hasil manual operation. Karena kalau ujian dan assignment harus manual.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: