Home

0b

0b is a prefix used in several programming languages to denote that the following digits form a binary integer literal. When written as 0b followed by a sequence of 0s and 1s, the value is interpreted in base-2. The prefix is typically case-insensitive, so 0b and 0B are treated the same.

The 0b prefix is supported in a number of popular languages. In Python, 0b1010 evaluates to decimal

Syntax and rules: A binary literal consists of the prefix 0b or 0B followed by digits restricted

Limitations and context: The 0b prefix is not part of data interchange formats such as JSON, which

See also: hexadecimal prefix 0x, numeral systems, binary literals.

10;
since
Python
3.6,
digits
can
include
underscores
for
readability,
as
in
0b1010_0101.
In
JavaScript
(ECMAScript
2015
and
later),
0b11110000
denotes
a
binary
integer.
In
Rust,
binary
literals
use
0b
and
0B,
with
the
actual
value
determined
by
the
type
context.
to
0
and
1.
The
exact
treatment
of
the
literal—such
as
its
type,
signedness,
or
width—depends
on
the
language
and
the
surrounding
code.
Some
languages
allow
digit
separators
(like
underscores)
for
readability,
while
others
require
continuous
digits.
do
not
define
binary
literals.
It
is
primarily
a
programming-language
feature
used
in
source
code
and,
where
supported,
compiled
or
interpreted
accordingly.