<s>
Bit	B-Algorithm
manipulation	I-Algorithm
is	O
the	O
act	O
of	O
algorithmically	O
manipulating	O
bits	O
or	O
other	O
pieces	O
of	O
data	B-General_Concept
shorter	O
than	O
a	O
word	O
.	O
</s>
<s>
Computer	B-General_Concept
programming	I-General_Concept
tasks	O
that	O
require	O
bit	B-Algorithm
manipulation	I-Algorithm
include	O
low-level	O
device	O
control	O
,	O
error	B-Error_Name
detection	I-Error_Name
and	I-Error_Name
correction	I-Error_Name
algorithms	O
,	O
data	B-General_Concept
compression	I-General_Concept
,	O
encryption	O
algorithms	O
,	O
and	O
optimization	O
.	O
</s>
<s>
For	O
most	O
other	O
tasks	O
,	O
modern	O
programming	O
languages	O
allow	O
the	O
programmer	B-Application
to	O
work	O
directly	O
with	O
abstractions	B-Application
instead	O
of	O
bits	O
that	O
represent	O
those	O
abstractions	B-Application
.	O
</s>
<s>
Source	O
code	O
that	O
does	O
bit	B-Algorithm
manipulation	I-Algorithm
makes	O
use	O
of	O
the	O
bitwise	O
operations	O
:	O
AND	O
,	O
OR	O
,	O
XOR	O
,	O
NOT	O
,	O
and	O
possibly	O
other	O
operations	O
analogous	O
to	O
the	O
boolean	O
operators	O
;	O
there	O
are	O
also	O
bit	O
shifts	O
and	O
operations	O
to	O
count	O
ones	O
and	O
zeros	O
,	O
find	O
high	O
and	O
low	O
one	O
or	O
zero	O
,	O
set	O
,	O
reset	O
and	O
test	O
bits	O
,	O
extract	O
and	O
insert	O
fields	O
,	O
mask	O
and	O
zero	O
fields	O
,	O
gather	O
and	O
scatter	O
bits	O
to	O
and	O
from	O
specified	O
bit	O
positions	O
or	O
fields	O
.	O
</s>
<s>
Bit	B-Algorithm
manipulation	I-Algorithm
,	O
in	O
some	O
cases	O
,	O
can	O
obviate	O
or	O
reduce	O
the	O
need	O
to	O
loop	O
over	O
a	O
data	B-General_Concept
structure	O
and	O
can	O
give	O
many-fold	O
speed	O
ups	O
,	O
as	O
bit	B-Algorithm
manipulations	I-Algorithm
are	O
processed	O
in	O
parallel	O
.	O
</s>
<s>
Bit	B-Algorithm
twiddling	I-Algorithm
,	O
bit	B-Algorithm
fiddling	I-Algorithm
,	O
and	O
bit	B-Algorithm
bashing	I-Algorithm
are	O
often	O
used	O
interchangeably	O
with	O
bit	B-Algorithm
manipulation	I-Algorithm
,	O
but	O
sometimes	O
exclusively	O
refer	O
to	O
clever	O
or	O
non-obvious	O
ways	O
or	O
uses	O
of	O
bit	B-Algorithm
manipulation	I-Algorithm
,	O
or	O
tedious	O
or	O
challenging	O
low-level	O
device	O
control	O
data	B-General_Concept
manipulation	O
tasks	O
.	O
</s>
<s>
The	O
term	O
bit	B-Algorithm
twiddling	I-Algorithm
dates	O
from	O
early	B-Architecture
computing	I-Architecture
hardware	I-Architecture
,	O
where	O
computer	O
operators	O
would	O
make	O
adjustments	O
by	O
tweaking	O
or	O
twiddling	O
computer	O
controls	O
.	O
</s>
<s>
As	O
computer	B-General_Concept
programming	I-General_Concept
languages	O
evolved	O
,	O
programmers	B-Application
adopted	O
the	O
term	O
to	O
mean	O
any	O
handling	O
of	O
data	B-General_Concept
that	O
involved	O
bit-level	O
computation	O
.	O
</s>
<s>
It	O
is	O
a	O
fast	O
,	O
primitive	O
action	O
directly	O
supported	O
by	O
the	O
central	B-General_Concept
processing	I-General_Concept
unit	I-General_Concept
(	O
CPU	O
)	O
,	O
and	O
is	O
used	O
to	O
manipulate	O
values	O
for	O
comparisons	O
and	O
calculations	O
.	O
</s>
<s>
While	O
modern	O
processors	O
usually	O
perform	O
some	O
arithmetic	O
and	O
logical	O
operations	O
just	O
as	O
fast	O
as	O
bitwise	O
operations	O
due	O
to	O
their	O
longer	O
instruction	B-General_Concept
pipelines	I-General_Concept
and	O
other	O
architectural	B-General_Concept
design	O
choices	O
,	O
bitwise	O
operations	O
do	O
commonly	O
use	O
less	O
power	O
because	O
of	O
the	O
reduced	O
use	O
of	O
resources	O
.	O
</s>
<s>
If	O
inline	O
assembly	B-Language
language	I-Language
code	O
is	O
used	O
,	O
then	O
an	O
instruction	O
that	O
counts	O
the	O
number	O
of	O
1	O
's	O
or	O
0	O
's	O
in	O
the	O
operand	O
might	O
be	O
available	O
;	O
an	O
operand	O
with	O
exactly	O
one	O
'	O
1	O
 '	O
bit	O
is	O
a	O
power	O
of	O
2	O
.	O
</s>
<s>
A	O
mask	O
is	O
data	B-General_Concept
that	O
is	O
used	O
for	O
bitwise	O
operations	O
,	O
particularly	O
in	O
a	O
bit	O
field	O
.	O
</s>
<s>
Using	O
a	O
mask	O
,	O
multiple	O
bits	O
in	O
a	O
Byte	B-Application
,	O
nibble	O
,	O
word	O
(	O
etc	O
.	O
)	O
</s>
<s>
More	O
comprehensive	O
applications	O
of	O
masking	O
,	O
when	O
applied	O
conditionally	O
to	O
operations	O
,	O
are	O
termed	O
predication	B-General_Concept
.	O
</s>
