<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"ref.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"ref.html" title='Python Reference Manual'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"floating.html" />
<link rel=
"prev" href=
"numbers.html" />
<link rel=
"parent" href=
"literals.html" />
<link rel=
"next" href=
"floating.html" />
<meta name='aesop' content='information'
/>
<title>2.4.4 Integer and long integer literals
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"2.4.3 Numeric literals"
href=
"numbers.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"2.4 Literals"
href=
"literals.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"2.4.5 Floating point literals"
href=
"floating.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Reference Manual
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><img src='../icons/blank.png'
border='
0' height='
32' alt='' width='
32'
/></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"numbers.html">2.4.3 Numeric literals
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"literals.html">2.4 Literals
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"floating.html">2.4.5 Floating point literals
</A>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION004440000000000000000"></A><A NAME=
"integers"></A>
2.4.4 Integer and long integer literals
Integer and long integer literals are described by the following
<div class=
"productions">
<td><a id='tok-longinteger' xml:id='tok-longinteger'
>longinteger
</a></td>
<td><a class='grammartoken'
href=
"integers.html#tok-integer">integer
</a> (
"l" |
"L")
</td></tr>
<td><a id='tok-integer' xml:id='tok-integer'
>integer
</a></td>
<td><a class='grammartoken'
href=
"integers.html#tok-decimalinteger">decimalinteger
</a> |
<a class='grammartoken'
href=
"integers.html#tok-octinteger">octinteger
</a> |
<a class='grammartoken'
href=
"integers.html#tok-hexinteger">hexinteger
</a></td></tr>
<td><a id='tok-decimalinteger' xml:id='tok-decimalinteger'
>decimalinteger
</a></td>
<td><a class='grammartoken'
href=
"integers.html#tok-nonzerodigit">nonzerodigit
</a> <a class='grammartoken'
href=
"identifiers.html#tok-digit">digit
</a>* |
"0"</td></tr>
<td><a id='tok-octinteger' xml:id='tok-octinteger'
>octinteger
</a></td>
<td>"0" <a class='grammartoken'
href=
"integers.html#tok-octdigit">octdigit
</a>+
</td></tr>
<td><a id='tok-hexinteger' xml:id='tok-hexinteger'
>hexinteger
</a></td>
<td>"0" (
"x" |
"X")
<a class='grammartoken'
href=
"integers.html#tok-hexdigit">hexdigit
</a>+
</td></tr>
<td><a id='tok-nonzerodigit' xml:id='tok-nonzerodigit'
>nonzerodigit
</a></td>
<td><a id='tok-octdigit' xml:id='tok-octdigit'
>octdigit
</a></td>
<td><a id='tok-hexdigit' xml:id='tok-hexdigit'
>hexdigit
</a></td>
<td><a class='grammartoken'
href=
"identifiers.html#tok-digit">digit
</a> |
"a"...
"f" |
"A"...
"F"</td></tr>
<a class=
"grammar-footer"
href=
"grammar.txt" type=
"text/plain"
>Download entire grammar as text.
</a>
Although both lower case
"<tt class="character
">l</tt>" and upper case
"<tt class="character
">L</tt>" are
allowed as suffix for long integers, it is strongly recommended to always
use
"<tt class="character
">L</tt>", since the letter
"<tt class="character
">l</tt>" looks too much like the
digit
"<tt class="character
">1</tt>".
Plain integer literals that are above the largest representable plain
integer (e.g.,
2147483647 when using
32-bit arithmetic) are accepted
as if they were long integers instead.
<A NAME=
"tex2html1"
HREF=
"#foot461"><SUP>2.1</SUP></A> There is no limit for long integer
literals apart from what can be stored in available memory.
Some examples of plain integer literals (first row) and long integer
literals (second and third rows):
<div class=
"verbatim"><pre>
3L 79228162514264337593543950336L 0377L 0x100000000L
79228162514264337593543950336 0xdeadbeef
<BR><HR><H4>Footnotes
</H4>
<DT><A NAME=
"foot461">... instead.
</A><A
href=
"integers.html#tex2html1"><SUP>2.1</SUP></A></DT>
<DD>In versions of Python
prior to
2.4, octal and hexadecimal literals in the range just above
the largest representable plain integer but below the largest unsigned
32-bit number (on a machine using
32-bit arithmetic),
4294967296, were
taken as the negative plain integer obtained by subtracting
4294967296
from their unsigned value.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"2.4.3 Numeric literals"
href=
"numbers.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"2.4 Literals"
href=
"literals.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"2.4.5 Floating point literals"
href=
"floating.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Reference Manual
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><img src='../icons/blank.png'
border='
0' height='
32' alt='' width='
32'
/></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"numbers.html">2.4.3 Numeric literals
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"literals.html">2.4 Literals
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"floating.html">2.4.5 Floating point literals
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.