<s>
A	O
division	B-Algorithm
algorithm	I-Algorithm
is	O
an	O
algorithm	O
which	O
,	O
given	O
two	O
integers	O
N	O
and	O
D	O
(	O
respectively	O
the	O
numerator	O
and	O
the	O
denominator	O
)	O
,	O
computes	O
their	O
quotient	O
and/or	O
remainder	O
,	O
the	O
result	O
of	O
Euclidean	O
division	O
.	O
</s>
<s>
Division	B-Algorithm
algorithms	I-Algorithm
fall	O
into	O
two	O
main	O
categories	O
:	O
slow	O
division	O
and	O
fast	O
division	O
.	O
</s>
<s>
Slow	O
division	B-Algorithm
algorithms	I-Algorithm
produce	O
one	O
digit	O
of	O
the	O
final	O
quotient	O
per	O
iteration	O
.	O
</s>
<s>
Variants	O
of	O
these	O
algorithms	O
allow	O
using	O
fast	B-Algorithm
multiplication	I-Algorithm
algorithms	O
.	O
</s>
<s>
It	O
results	O
that	O
,	O
for	O
large	O
integers	O
,	O
the	O
computer	O
time	O
needed	O
for	O
a	O
division	O
is	O
the	O
same	O
,	O
up	O
to	O
a	O
constant	O
factor	O
,	O
as	O
the	O
time	O
needed	O
for	O
a	O
multiplication	O
,	O
whichever	O
multiplication	B-Algorithm
algorithm	I-Algorithm
is	O
used	O
.	O
</s>
<s>
The	O
simplest	O
division	B-Algorithm
algorithm	I-Algorithm
,	O
historically	O
incorporated	O
into	O
a	O
greatest	O
common	O
divisor	O
algorithm	O
presented	O
in	O
Euclid	O
's	O
Elements	O
,	O
Book	O
VII	O
,	O
Proposition	O
1	O
,	O
finds	O
the	O
remainder	O
given	O
two	O
positive	O
integers	O
using	O
only	O
subtractions	O
and	O
comparisons	O
:	O
</s>
<s>
The	O
proof	O
that	O
the	O
quotient	O
and	O
remainder	O
exist	O
and	O
are	O
unique	O
(	O
described	O
at	O
Euclidean	O
division	O
)	O
gives	O
rise	O
to	O
a	O
complete	O
division	B-Algorithm
algorithm	I-Algorithm
,	O
applicable	O
to	O
both	O
negative	O
and	O
positive	O
numbers	O
,	O
using	O
additions	O
,	O
subtractions	O
,	O
and	O
comparisons	O
:	O
</s>
<s>
Although	O
very	O
simple	O
,	O
it	O
takes	O
(	O
Q	O
)	O
steps	O
,	O
and	O
so	O
is	O
exponentially	O
slower	O
than	O
even	O
slow	O
division	B-Algorithm
algorithms	I-Algorithm
like	O
long	B-Algorithm
division	I-Algorithm
.	O
</s>
<s>
It	O
is	O
useful	O
if	O
Q	O
is	O
known	O
to	O
be	O
small	O
(	O
being	O
an	O
output-sensitive	B-Language
algorithm	I-Language
)	O
,	O
and	O
can	O
serve	O
as	O
an	O
executable	O
specification	O
.	O
</s>
<s>
Long	B-Algorithm
division	I-Algorithm
is	O
the	O
standard	O
algorithm	O
used	O
for	O
pen-and-paper	O
division	O
of	O
multi-digit	O
numbers	O
expressed	O
in	O
decimal	O
notation	O
.	O
</s>
<s>
Short	O
division	O
is	O
an	O
abbreviated	O
form	O
of	O
long	B-Algorithm
division	I-Algorithm
suitable	O
for	O
one-digit	O
divisors	O
.	O
</s>
<s>
Chunking	O
also	O
known	O
as	O
the	O
partial	O
quotients	O
method	O
or	O
the	O
hangman	O
method	O
is	O
a	O
less-efficient	O
form	O
of	O
long	B-Algorithm
division	I-Algorithm
which	O
may	O
be	O
easier	O
to	O
understand	O
.	O
</s>
<s>
By	O
allowing	O
one	O
to	O
subtract	O
more	O
multiples	O
than	O
what	O
one	O
currently	O
has	O
at	O
each	O
stage	O
,	O
a	O
more	O
freeform	O
variant	O
of	O
long	B-Algorithm
division	I-Algorithm
can	O
be	O
developed	O
as	O
well	O
.	O
</s>
<s>
The	O
following	O
algorithm	O
,	O
the	O
binary	O
version	O
of	O
the	O
famous	O
long	B-Algorithm
division	I-Algorithm
,	O
will	O
divide	O
N	O
by	O
D	O
,	O
placing	O
the	O
quotient	O
in	O
Q	O
and	O
the	O
remainder	O
in	O
R	O
.	O
In	O
the	O
following	O
pseudo-code	O
,	O
all	O
values	O
are	O
treated	O
as	O
unsigned	O
integers	O
.	O
</s>
<s>
SRT	O
division	O
is	O
a	O
popular	O
method	O
for	O
division	O
in	O
many	O
microprocessor	B-Architecture
implementations	O
.	O
</s>
<s>
SRT	O
division	O
is	O
similar	O
to	O
non-restoring	O
division	O
,	O
but	O
it	O
uses	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
based	O
on	O
the	O
dividend	O
and	O
the	O
divisor	O
to	O
determine	O
each	O
quotient	O
digit	O
.	O
</s>
<s>
The	O
Intel	B-General_Concept
Pentium	I-General_Concept
processor	O
's	O
infamous	B-Device
floating-point	I-Device
division	I-Device
bug	I-Device
was	O
caused	O
by	O
an	O
incorrectly	O
coded	O
lookup	B-Data_Structure
table	I-Data_Structure
.	O
</s>
<s>
To	O
obtain	O
a	O
result	O
with	O
a	O
precision	B-General_Concept
of	O
2n	O
bits	O
while	O
making	O
use	O
of	O
the	O
second	O
expression	O
,	O
one	O
must	O
compute	O
the	O
product	O
between	O
and	O
with	O
double	O
the	O
given	O
precision	B-General_Concept
of	O
(	O
n	O
bits	O
)	O
.	O
</s>
<s>
In	O
contrast	O
,	O
the	O
product	O
between	O
and	O
need	O
only	O
be	O
computed	O
with	O
a	O
precision	B-General_Concept
of	O
n	O
bits	O
,	O
because	O
the	O
leading	O
n	O
bits	O
(	O
after	O
the	O
binary	O
point	O
)	O
of	O
are	O
zeros	O
.	O
</s>
<s>
This	O
squaring	O
of	O
the	O
error	O
at	O
each	O
iteration	O
step	O
the	O
so-called	O
quadratic	O
convergence	B-Architecture
of	O
Raphson	O
's	O
method	O
has	O
the	O
effect	O
that	O
the	O
number	O
of	O
correct	O
digits	O
in	O
the	O
result	O
roughly	O
doubles	O
for	O
every	O
iteration	O
,	O
a	O
property	O
that	O
becomes	O
extremely	O
valuable	O
when	O
the	O
numbers	O
involved	O
have	O
many	O
digits	O
(	O
e.g.	O
</s>
<s>
But	O
it	O
also	O
means	O
that	O
the	O
initial	O
convergence	B-Architecture
of	O
the	O
method	O
can	O
be	O
comparatively	O
slow	O
,	O
especially	O
if	O
the	O
initial	O
estimate	O
is	O
poorly	O
chosen	O
.	O
</s>
<s>
This	O
evaluates	O
to	O
3	O
for	O
IEEE	O
single	O
precision	B-General_Concept
and	O
4	O
for	O
both	O
double	O
precision	B-General_Concept
and	O
double	B-Algorithm
extended	I-Algorithm
formats	O
.	O
</s>
<s>
The	O
following	O
computes	O
the	O
quotient	O
of	O
and	O
with	O
a	O
precision	B-General_Concept
of	O
binary	O
places	O
:	O
</s>
<s>
For	O
example	O
,	O
for	O
a	O
double-precision	O
floating-point	B-Algorithm
division	O
,	O
this	O
method	O
uses	O
10	O
multiplies	O
,	O
9	O
adds	O
,	O
and	O
2	O
shifts	O
.	O
</s>
<s>
which	O
is	O
maximum	O
at	O
when	O
,	O
thus	O
providing	O
a	O
minimum	O
precision	B-General_Concept
of	O
binary	O
digits	O
.	O
</s>
<s>
For	O
these	O
large	O
integers	O
,	O
more	O
efficient	O
division	B-Algorithm
algorithms	I-Algorithm
transform	O
the	O
problem	O
to	O
use	O
a	O
small	O
number	O
of	O
multiplications	O
,	O
which	O
can	O
then	O
be	O
done	O
using	O
an	O
asymptotically	O
efficient	O
multiplication	B-Algorithm
algorithm	I-Algorithm
such	O
as	O
the	O
Karatsuba	B-Algorithm
algorithm	I-Algorithm
,	O
Toom	B-Algorithm
–	I-Algorithm
Cook	I-Algorithm
multiplication	I-Algorithm
or	O
the	O
Schönhage	B-Algorithm
–	I-Algorithm
Strassen	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
Examples	O
include	O
reduction	O
to	O
multiplication	O
by	O
Newton	O
's	O
method	O
as	O
described	O
above	O
,	O
as	O
well	O
as	O
the	O
slightly	O
faster	O
Burnikel-Ziegler	O
division	O
,	O
Barrett	B-Algorithm
reduction	I-Algorithm
and	O
Montgomery	B-Algorithm
reduction	I-Algorithm
algorithms	O
.	O
</s>
<s>
Thus	O
it	O
is	O
possible	O
to	O
compute	O
the	O
value	O
of	O
(	O
1/D	O
)	O
once	O
at	O
compile	B-Language
time	O
,	O
and	O
at	O
run	O
time	O
perform	O
the	O
multiplication	O
N·( 	O
1/D	O
)	O
rather	O
than	O
the	O
division	O
N/D	O
.	O
</s>
<s>
In	O
floating-point	B-Algorithm
arithmetic	I-Algorithm
the	O
use	O
of	O
(	O
1/D	O
)	O
presents	O
little	O
problem	O
,	O
but	O
in	O
integer	O
arithmetic	O
the	O
reciprocal	O
will	O
always	O
evaluate	O
to	O
zero	O
(	O
assuming	O
|D|	O
>	O
1	O
)	O
.	O
</s>
<s>
Barrett	B-Algorithm
reduction	I-Algorithm
uses	O
powers	O
of	O
2	O
for	O
the	O
value	O
of	O
Y	O
to	O
make	O
division	O
by	O
Y	O
a	O
simple	O
right	O
shift	O
.	O
</s>
<s>
Round-off	B-Algorithm
error	I-Algorithm
can	O
be	O
introduced	O
by	O
division	O
operations	O
due	O
to	O
limited	O
precision	B-General_Concept
.	O
</s>
