help with long division

closed account (Dy7SLyTq)
so im learning binary representation for assembly and learned the long division method using this: http://www.wikihow.com/Convert-from-Decimal-to-Binary . ive got it down now (by checking my work with this: http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html my question is, will it work to convert any base to another? could i use it to convert decimal to binary or hex to octal?
Last edited on
Yes, convert to decimal then to the desired base.
closed account (Dy7SLyTq)
so then this works: base10/base16 and base16/base10
Last edited on
No, sorry the division method only works dec to another base (IIRC). I thought you meant if the conversion will work, not specifically the division method (need to read slower)
closed account (9wqjE3v7)
The third method on that site, can apply to any other numerical base system.
closed account (Dy7SLyTq)
alright thanks. just one more thing: what about base 16? how am i supposed to deal with a-f? using long division?
Division has no base. The "base" property is a result of the divisor on the quotient.

Dividing 10102 by 1012 is the same as dividing A16 by 516 is the same as dividing 10 by 5.

A number is a number is a number.

The idea of base (or radix) is useful in terms of how we humans view numbers.

So, as long as you have a number in some format that you can use to divide it by your radix number, you are good to go. This is particularly useful when you have your number stored in an int, since you can divide an int by any random base you choose easily enough.


int x = 10;
x % 2 = 0; x /= 2 = 5;
x % 2 = 1; x /= 2 = 2;
x % 2 = 0; x /= 2 = 1;
x % 2 = 1; x /= 2 = 0;
        ↑
        
binary representation

Binary representation is 1010.

Hope this helps.
closed account (Dy7SLyTq)
i understand that, but lets say i divide 1110 by base 16, it should be i think B. how would i know that it contains a number if its larger than 16
I don't understand what you mean by "contains a number if its larger than 16".

11 % 16 = 11 (or 'B')
11 / 16 = 0
all done: result = B

18 % 16 = 2, 17 / 16 = 1
 1 % 16 = 1,  1 / 16 = 0
all done: result = 12
Topic archived. No new replies allowed.