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!
=== Short integer === A ''short integer'' can represent a whole number that may take less storage, while having a smaller range, compared with a standard integer on the same machine. In [[C (programming language)|C]], it is denoted by {{mono|short}}. It is required to be at least 16 bits, and is often smaller than a standard integer, but this is not required.<ref name="c99" /><ref name="drdobbsinteger" /> A conforming program can assume that it can safely store values between โ(2<sup>15</sup>โ1)<ref name="c-std-6.2.6.2p2">{{cite web |url=http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf |at=section 6.2.6.2, paragraph 2|title=ISO/IEC 9899:201x |access-date=2016-06-20 |publisher=open-std.org}}</ref> and 2<sup>15</sup>โ1,<ref name="c-std-5.2.4.2.1">{{cite web |url=http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf |at=section 5.2.4.2.1|title=ISO/IEC 9899:201x |access-date=2016-06-20 |publisher=open-std.org}}</ref> but it may not assume that the range is not larger. In [[Java (programming language)|Java]], a {{mono|short}} is ''always'' a 16-bit integer. In the [[Windows API]], the datatype {{mono|SHORT}} is defined as a 16-bit signed integer on all machines.<ref name="agnerfog" /> {| class="wikitable" |+ Common short integer sizes |- ! [[Programming language]] ! Data type name ! [[Signedness]] ! Size in [[bytes]] ! Minimum value ! Maximum value |- | rowspan="2" | [[C (programming language)|C]] and [[C++]] | {{mono|short}} | signed | style="text-align: right;" | 2 | style="text-align: right;" | โ32,767{{efn|The ISO C standard allows implementations to reserve the value with sign bit 1 and all other bits 0 (for signโmagnitude and two's complement representation) or with all bits 1 (for ones' complement) for use as a "trap" value, used to indicate (for example) an overflow.<ref name="c-std-6.2.6.2p2" />}} | style="text-align: right;" | +32,767 |- | {{mono|unsigned short}} | unsigned | style="text-align: right;" | 2 | style="text-align: right;" | 0 | style="text-align: right;" | 65,535 |- | rowspan="2" | [[C Sharp (programming language)|C#]] | {{mono|short}} | signed | style="text-align: right;" | 2 | style="text-align: right;" | โ32,768 | style="text-align: right;" | +32,767 |- | {{mono|ushort}} | unsigned | style="text-align: right;" | 2 | style="text-align: right;" | 0 | style="text-align: right;" | 65,535 |- | [[Java (programming language)|Java]] | {{mono|short}} | signed | style="text-align: right;" | 2 | style="text-align: right;" | โ32,768 | style="text-align: right;" | +32,767 |- | [[SQL]] | {{mono|smallint}} | signed | style="text-align: right;" | 2 <!-- (implementation-defined) --> | style="text-align: right;" | โ32,768 | style="text-align: right;" | +32,767 |}
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