The MASM Forum

General => The Campus => Topic started by: Evan on December 10, 2013, 02:40:05 PM

Title: I looked at this and decided to do -5 * -4 in binary.
Post by: Evan on December 10, 2013, 02:40:05 PM
I messed up.
http://fourier.eng.hmc.edu/e85_old/lectures/arithmetic_html/node9.html (http://fourier.eng.hmc.edu/e85_old/lectures/arithmetic_html/node9.html)


I messed up again.

I think it is:
111011
111100
_______
     000000
    000000
   111011
  111011
111011
111011
_______
1111 0111100100


I read my code
left to right
first I count the ones
second I count the zeros
third I count the ones' segments
forth I count the zeros' segments

.

Please let me know why I am wrong.

My programmer calculator says -5 * -4 is -1. Weird.


Due to my calculator I think I need to take 15864 - (my code) to correct the result.
Title: Re: I looked at this and decided to do -5 * -4 in binary.
Post by: gelatine1 on December 10, 2013, 10:24:14 PM
(http://img600.imageshack.us/img600/9704/6r5n.png)

Do 4*5 instead and then take 2's complement. The thing marked in yellow should be your result. EDIT: don't take 2's complement...
For binary multiplications I.
would suggest this algorithm http://en.wikipedia.org/wiki/Multiplication_algorithm#Peasant_or_binary_multiplication
In fact it is just the same as long multiplication though.
Title: Re: I looked at this and decided to do -5 * -4 in binary.
Post by: Evan on December 11, 2013, 07:31:40 PM
Quote from: gelatine1 link=topic=2708.msg28757#msg28757 date=1386674654 #delete image from above


Do 4*5 instead and then take 2's complement. The thing marked in yellow should be your result. EDIT: don't take 2's complement...
For binary multiplications I.
would suggest this algorithm http://en.wikipedia.org/wiki/Multiplication_algorithm#Peasant_or_binary_multiplication (http://en.wikipedia.org/wiki/Multiplication_algorithm#Peasant_or_binary_multiplication)
In fact it is just the same as long multiplication though.

In my system's calculator the number I found for -20 doesn't matter after many ghost errors. What you showed me I do not understand.
Title: Re: I looked at this and decided to do -5 * -4 in binary.
Post by: Evan on December 11, 2013, 07:39:51 PM
Should we explain long multiplication to each other on smaller number scales?
Should we use the decimal point in our long multiplication?


Please move this to the romper.