Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Integer (computer science)
(section)
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 |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)