Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Integer (computer science)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Syntax == {{main|Integer literal}} [[Integer literal]]s can be written as regular [[Arabic numerals]], consisting of a sequence of digits and with negation indicated by a [[hyphen-minus|minus sign]] before the value. However, most programming languages disallow use of commas or spaces for [[digit grouping]]. Examples of integer literals are: * <code>42</code> * <code>10000</code> * <code>-233000</code> <!-- do not use the real minus sign, as that isn't part of a literal --> There are several alternate methods for writing integer literals in many programming languages: * Many programming languages, especially those influenced by [[C (programming language)|C]], prefix an integer literal with <code>0X</code> or <code>0x</code> to represent a [[hexadecimal]] value, e.g. <code>0xDEADBEEF</code>. Other languages may use a different notation, e.g. some [[assembly language]]s append an <code>H</code> or <code>h</code> to the end of a hexadecimal value. * [[Perl]], [[Ruby (programming language)|Ruby]], [[Java (programming language)|Java]], [[Julia (programming language)|Julia]], [[D (programming language)|D]], [[Go (programming language)|Go]], [[C Sharp (programming language)|C#]], [[Rust (programming language)|Rust]], [[Python (programming language)|Python]] (starting from version 3.6), and [[PHP]] (from version 7.4.0 onwards<ref>https://www.php.net/manual/en/language.types.integer.php</ref>) allow embedded [[underscore]]s for clarity, e.g. <code>10_000_000</code>, and fixed-form [[Fortran]] ignores embedded spaces in integer literals. C (starting from [[C23 (C standard revision)|C23]]) and C++ use single quotes for this purpose. * In [[C (programming language)|C]] and [[C++]], a leading zero indicates an [[octal]] value, e.g. <code>0755</code>. This was primarily intended to be used with [[Modes (Unix)|Unix modes]]; however, it has been criticized because normal integers may also lead with zero.<ref>ECMAScript 6th Edition draft: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-numeric-literals {{webarchive|url=https://web.archive.org/web/20131216202526/https://people.mozilla.org/~jorendorff/es6-draft.html |date=2013-12-16 }}</ref> As such, [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Haskell]], and [[OCaml]] prefix octal values with <code>0O</code> or <code>0o</code>, following the layout used by hexadecimal values. * Several languages, including [[Java (programming language)|Java]], [[C Sharp (programming language)|C#]], [[Scala (programming language)|Scala]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[OCaml]], C (starting from C23) and C++ can represent binary values by prefixing a number with <code>0B</code> or <code>0b</code>.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Integer (computer science)
(section)
Add topic