Home

0b111

0b111 is a binary literal that uses the 0b prefix to indicate that the digits following are in base 2. In binary, the digits 111 equal 1×4 + 1×2 + 1×1, which is the decimal value 7 when interpreted as unsigned.

In contexts with fixed-width signed integers, the meaning of the bit pattern 111 can depend on the

Common uses of binary literals like 0b111 include bitwise operations and bit masking. The pattern 0b111 has

Language and notation notes: many modern programming languages provide 0b-style binary literals, including languages such as

width
and
representation.
For
example,
in
a
3-bit
two’s-complement
system,
the
bit
pattern
111
encodes
-1,
while
in
a
larger
width
it
represents
7.
In
languages
that
support
binary
literals,
0b111
is
typically
treated
as
the
integer
7
unless
a
specific
width
or
signed
interpretation
is
applied
through
casting
or
type
rules.
the
lowest
three
bits
set,
which
can
be
combined
with
other
bit
patterns
to
enable,
disable,
or
test
particular
flag
bits.
For
instance,
bitwise
operations
involving
0b111
can
illustrate
how
multiple
binary
positions
interact
in
encoding
information
or
controlling
hardware
features.
Python,
JavaScript,
and
Java,
among
others.
The
0b
prefix
helps
distinguish
binary
numbers
from
decimal
and
hexadecimal
representations,
aiding
readability
and
reducing
conversion
errors
in
low-level
or
bit-oriented
code.