
quest..
I'm writing this class call hugeint, and part of writing this class is having function like add, subtract, multiply... So far i cover +,,*,<,>,==,!= but when it comes to division i dont think i'm doin' it the best way. What i done so far is ask for 2 number (whithin' a 40 digit limit) and subtract the 2 numbers until the first is less than the second and keep track of how many times i've subtracted the numbers and return the count.
My question is how does a computer divide to integers, lets say 25 and 5??

You can divide binary numbers the same way you divide base10 numbers. Floating point division is much different.
Code:
25 / 5
11001 / 101
11001
 101 > 1

10 > 0

101
 101 > 1
11001 / 101 = 101
Here's another example:
Code:
28 / 3
11100 / 11
11100
 11 > 1

01 > 0

010 > 0

0100
 11 > 1

1
ran out
11100 / 11 = 1001 R1
1001 = 9
9 * 3 = 27
1 = 1
Remainder 1
In other words, use long division.

This applies specifically to binary numbers, but maybe it'll help...
http://courses.cs.vt.edu/%7Ecs1104/D....Subtract.html


I see what y'all saying but how would I divide a huge integer like 1234564231 / 124578??
Another thing i didn't mention is that the hugeint i kept in an array...
Thanx