Home

0o2002

0o2002 is an octal numeral written with the 0o prefix, a convention used by several programming languages to denote numbers in base eight. Languages such as Python (version 3 and later), JavaScript (ES6), and Rust adopt this explicit prefix to distinguish octal literals from decimal and hexadecimal literals.

In decimal terms, 0o2002 equals 1026. This is calculated as 2 × 8^3 + 0 × 8^2 + 0

Usage and notes: 0o2002 can appear in source code as a numeric constant, for example when specifying

×
8^1
+
2
×
8^0
=
1024
+
2
=
1026.
Its
hexadecimal
representation
is
0x402,
since
0x400
equals
1024
and
adding
0x2
yields
1026.
The
corresponding
binary
form
is
10000000010.
The
digits
2-0-0-2
reflect
the
octal
digits
that
form
the
value.
bit
masks,
configuration
values,
or
other
integer
literals.
It
is
distinct
from
Unix-style
file
permission
notations,
which
are
often
written
in
octal
but
indicate
permission
bits
rather
than
a
general
numeric
value.
In
Python
3,
0o2002
is
parsed
directly
as
the
integer
1026;
in
other
languages
the
exact
interpretation
depends
on
the
language’s
literal
rules.
Historically,
octal
literals
were
sometimes
written
with
a
leading
0
(without
the
o),
as
in
C
and
C++,
but
this
older
style
can
be
error-prone
and
is
less
common
in
modern
code.
See
also
octal
notation,
and
language-specific
literal
syntax.