longword int64 doubleword quadword std.org 9,223,372,036,854,775,807 9,223,372,036,854,775,808 bigint qword smallint 18,446,744,073,709,551,615 2,147,483,648 32,767 2,147,483,647 4,294,967,295 32,768 datatypes c99 201x 65,535 ecma signedness nibble giguere 9899 vba octets international.org madhusudhan integers
the range of value for the long type data is
Integer ( computer science ) - wikipedia Integer ( computer science ) Jump to : navigation , search In computer science , an integer is a datum of integral data type , a data type that represents some range of mathematical integers . Integral data types may be of different sizes and may or may not be allowed to contain negative values . Integers are commonly represented in a computer as a group of binary digits ( bits ) . The size of the grouping varies so the set of integer sizes available varies between different types of computers . Computer hardware , including virtual machines , nearly always provide a way to represent a processor register or memory address as an integer . Contents ( hide ) 1 Value and representation 2 Common integral data types 2.1 Bytes and octets 2.2 Words 2.3 Short integer 2.3. 1 Common short integer sizes 2.4 Long integer 2.4. 1 Common long integer sizes 2.5 Long long 3 See also 4 Notes 5 References Value and representation ( edit ) The value of an item with an integral type is the mathematical integer that it corresponds to . Integral types may be unsigned ( capable of representing only non-negative integers ) or signed ( capable of representing negative integers as well ) . An integer value is typically specified in the source code of a program as a sequence of digits optionally prefixed with + or − . Some programming languages allow other notations , such as hexadecimal ( base 16 ) or octal ( base 8 ) . Some programming languages also permit digit group separators . The internal representation of this datum is the way the value is stored in the computer 's memory . Unlike mathematical integers , a typical datum in a computer has some minimal and maximum possible value . The most common representation of a positive integer is a string of bits , using the binary numeral system . The order of the memory bytes storing the bits varies ; see endianness . The width or precision of an integral type is the number of bits in its representation . An integral type with n bits can encode 2 numbers ; for example an unsigned type typically represents the non-negative values 0 through 2 − 1 . Other encodings of integer values to bit patterns are sometimes used , for example Binary - coded decimal or Gray code , or as printed character codes such as ASCII . There are four well - known ways to represent signed numbers in a binary computing system . The most common is two 's complement , which allows a signed integral type with n bits to represent numbers from − 2 through 2 − 1 . Two 's complement arithmetic is convenient because there is a perfect one - to - one correspondence between representations and values ( in particular , no separate + 0 and − 0 ) , and because addition , subtraction and multiplication do not need to distinguish between signed and unsigned types . Other possibilities include offset binary , sign - magnitude , and ones ' complement . Some computer languages define integer sizes in a machine - independent way ; others have varying definitions depending on the underlying processor word size . Not all language implementations define variables of all integer sizes , and defined sizes may not even be distinct in a particular implementation . An integer in one programming language may be a different size in a different language or on a different processor . Common integral data types ( edit ) Bits Name Range ( assuming two 's complement for signed ) Decimal Digits ( approx . ) Uses <Th_colspan="5"> Implementations C / C++ C# Pascal and Delphi Java SQL nibble , semioctet Signed : From − 8 to 7 , from − ( 2 ) to 2 − 1 Binary - coded decimal , single decimal digit representation . n / a n / a n / a n / a n / a Unsigned : From 0 to 15 , which equals 2 − 1 8 byte , octet Signed : From − 128 to 127 , from − ( 2 ) to 2 − 1 ASCII characters int8_t , char sbyte Shortint byte tinyint Unsigned : From 0 to 255 , which equals 2 − 1 uint8_t , char byte Byte n / a unsigned tinyint 16 halfword , word , short Signed : From − 32,768 to 32,767 , from − ( 2 ) to 2 − 1 5 UCS - 2 characters int16_t , short , int short Smallint short smallint Unsigned : From 0 to 65,535 , which equals 2 − 1 5 uint16_t ushort Word char unsigned smallint 32 word , long , doubleword , longword , int Signed : From − 2,147,483,648 to 2,147,483,647 , from − ( 2 ) to 2 − 1 10 UTF - 32 characters , True color with alpha , FourCC , pointers in 32 - bit computing int32_t , int , long int LongInt ; Integer int int Unsigned : From 0 to 4,294,967,295 , which equals 2 − 1 10 uint32_t uint LongWord ; DWord ; Cardinal n / a unsigned int 64 word , doubleword , longword , long long , quad , quadword , qword , int64 Signed : From − 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 , from − ( 2 ) to 2 − 1 19 Time ( milliseconds since the Unix epoch ) , pointers in 64 - bit computing int64_t , long , long long long Int64 long bigint Unsigned : From 0 to 18,446,744,073,709,551,615 , which equals 2 − 1 20 uint64_t ulong UInt64 ; QWord n / a unsigned bigint 128 octaword , double quadword Signed : From − 170,141,183,460,469,231,731,687,303,715,884,105,728 to 170,141,183,460,469,231,731,687,303,715,884,105,727 , from − ( 2 ) to 2 − 1 39 Complicated scientific calculations , IPv6 addresses , GUIDs C : only available as non-standard compiler - specific extension n / a n / a n / a n / a Unsigned : From 0 to 340,282,366,920,938,463,463,374,607,431,768,211,455 , which equals 2 − 1 39 n n - bit integer ( general case ) Signed : ( − ( 2 ) ) to ( 2 − 1 ) <Td_colspan="2"> ⌈ ( n − 1 ) log 2 ⌉ <Td_colspan="5"> Ada : range - 2 * * ( n - 1 ) ... 2 * * ( n - 1 ) - 1 Unsigned : 0 to ( 2 − 1 ) <Td_colspan="2"> ⌈ n log 2 ⌉ <Td_colspan="5"> Ada : range 0 ... 2 * * n - 1 , mod 2 * * n ; standard libraries ' or third - party arbitrary arithmetic libraries ' BigDecimal or Decimal classes in many languages such as Python , C++ , etc . ^ Not all SQL dialects have unsigned datatypes . The sizes of char , short , int , long and long long in C / C++ are dependent upon the implementation of the language . The sizes of Delphi 's Integer and Cardinal are not guaranteed , varying from platform to platform ; usually defined as LongInt and LongWord respectively . ^ Java does not directly support arithmetic on char types . The results must be cast back into char from an int . Different CPUs support different integral data types . Typically , hardware will support both signed and unsigned types , but only a small , fixed set of widths . The table above lists integral type widths that are supported in hardware by common processors . High level programming languages provide more possibilities . It is common to have a ' double width ' integral type that has twice as many bits as the biggest hardware - supported type . Many languages also have bit - field types ( a specified number of bits , usually constrained to be less than the maximum hardware - supported width ) and range types ( that can represent only the integers in a specified range ) . Some languages , such as Lisp , Smalltalk , REXX , Haskell , Python , and Perl 6 support arbitrary precision integers ( also known as infinite precision integers or bignums ) . Other languages that do not support this concept as a top - level construct may have libraries available to represent very large numbers using arrays of smaller variables , such as Java 's BigInteger class or Perl 5 's `` bigint '' package . These use as much of the computer 's memory as is necessary to store the numbers ; however , a computer has only a finite amount of storage , so they too can only represent a finite subset of the mathematical integers . These schemes support very large numbers , for example one kilobyte of memory could be used to store numbers up to 2466 decimal digits long . A Boolean or Flag type is a type that can represent only two values : 0 and 1 , usually identified with false and true respectively . This type can be stored in memory using a single bit , but is often given a full byte for convenience of addressing and speed of access . A four - bit quantity is known as a nibble ( when eating , being smaller than a bite ) or nybble ( being a pun on the form of the word byte ) . One nibble corresponds to one digit in hexadecimal and holds one digit or a sign code in binary - coded decimal . Bytes and octets ( edit ) Main article : Byte The term byte initially meant ' the smallest addressable unit of memory ' . In the past , 5 - , 6 - , 7 - , 8 - , and 9 - bit bytes have all been used . There have also been computers that could address individual bits ( ' bit - addressed machine ' ) , or that could only address 16 - or 32 - bit quantities ( ' word - addressed machine ' ) . The term byte was usually not used at all in connection with bit - and word - addressed machines . The term octet always refers to an 8 - bit quantity . It is mostly used in the field of computer networking , where computers with different byte widths might have to communicate . In modern usage byte almost invariably means eight bits , since all other sizes have fallen into disuse ; thus byte has come to be synonymous with octet . Words ( edit ) Main article : Word ( data type ) The term ' word ' is used for a small group of bits that are handled simultaneously by processors of a particular architecture . The size of a word is thus CPU - specific . Many different word sizes have been used , including 6 - , 8 - , 12 - , 16 - , 18 - , 24 - , 32 - , 36 - , 39 - , 40 - , 48 - , 60 - , and 64 - bit . Since it is architectural , the size of a word is usually set by the first CPU in a family , rather than the characteristics of a later compatible CPU . The meanings of terms derived from word , such as longword , doubleword , quadword , and halfword , also vary with the CPU and OS . Practically all new desktop processors are capable of using 64 - bit words , though embedded processors with 8 - and 16 - bit word size are still common . The 36 - bit word length was common in the early days of computers . One important cause of non-portability of software is the incorrect assumption that all computers have the same word size as the computer used by the programmer . For example , if a programmer using the C language incorrectly declares as int a variable that will be used to store values greater than 2 − 1 , the program will fail on computers with 16 - bit integers . That variable should have been declared as long , which has at least 32 bits on any computer . Programmers may also incorrectly assume that a pointer can be converted to an integer without loss of information , which may work on ( some ) 32 - bit computers , but fail on 64 - bit computers with 64 - bit pointers and 32 - bit integers . Short integer ( edit ) 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 , it is denoted by short . It is required to be at least 16 bits , and is often smaller than a standard integer , but this is not required . A conforming program can assume that it can safely store values between − ( 2 − 1 ) and 2 − 1 , but it may not assume that the range is n't larger . In Java , a short is always a 16 - bit integer . In the Windows API , the datatype SHORT is defined as a 16 - bit signed integer on all machines . Common short integer sizes ( edit ) Programming language Platforms Data type name Signedness Storage in bytes Minimum value Maximum value C and C++ common implementations short signed − 32,767 + 32,767 unsigned short unsigned 0 65,535 C# . NET CLR / CTS short signed − 32,768 + 32,767 ushort unsigned 0 65,535 Java Java platform short signed − 32,768 + 32,767 Long integer ( edit ) A long integer can represent a whole integer whose range is greater than or equal to that of a standard integer on the same machine . In C , it is denoted by long . It is required to be at least 32 bits , and may or may not be larger than a standard integer . A conforming program can assume that it can safely store values between − ( 2 − 1 ) and 2 − 1 , but it may not assume that the range is n't larger . Common long integer sizes ( edit ) Programming language Approval Type Platforms Data type name Storage in bytes Signed range Unsigned range C ISO / ANSI C99 International Standard Unix , 16 / 32 - bit systems Windows , 16 / 32 / 64 - bit systems long ( minimum requirement 4 ) − 2,147,483,647 to + 2,147,483,647 0 to 4,294,967,295 ( minimum requirement ) C ISO / ANSI C99 International Standard Unix , 64 - bit systems long 8 ( minimum requirement 4 ) − 9,223,372,036,854,775,807 to + 9,223,372,036,854,775,807 0 to 18,446,744,073,709,551,615 C++ ISO / ANSI International Standard Unix , Windows , 16 / 32 - bit system long ( minimum requirement 4 ) − 2,147,483,648 to + 2,147,483,647 0 to 4,294,967,295 ( minimum requirement ) C++ / CLI International Standard ECMA - 372 Unix , Windows , 16 / 32 - bit systems long ( minimum requirement 4 ) − 2,147,483,648 to + 2,147,483,647 0 to 4,294,967,295 ( minimum requirement ) VB Company Standard Windows Long − 2,147,483,648 to + 2,147,483,647 N / A VBA Company Standard Windows , Mac OS X Long − 2,147,483,648 to + 2,147,483,647 N / A SQL Server Company Standard Windows BigInt 8 − 9,223,372,036,854,775,808 to + 9,223,372,036,854,775,807 0 to 18,446,744,073,709,551,615 C# / VB.NET ECMA International Standard Microsoft . NET long or Int64 8 − 9,223,372,036,854,775,808 to + 9,223,372,036,854,775,807 0 to 18,446,744,073,709,551,615 Java International / Company Standard Java platform long 8 − 9,223,372,036,854,775,808 to + 9,223,372,036,854,775,807 N / A Pascal ? Windows , UNIX int64 8 − 9,223,372,036,854,775,808 to + 9,223,372,036,854,775,807 0 to 18,446,744,073,709,551,615 ( Qword type ) the term long int is equivalent Long long ( edit ) In the C99 version of the C programming language and the C + + 11 version of C++ , a long long type is supported that has double the minimum capacity of the standard long . This type is not supported by compilers that require C code to be compliant with the previous C++ standard , C + + 03 , because the long long type did not exist in C + + 03 . For an ANSI / ISO compliant compiler , the minimum requirements for the specified ranges , that is , − ( 2 − 1 ) to 2 − 1 for signed and 0 to 2 − 1 for unsigned , must be fulfilled ; however , extending this range is permitted . This can be an issue when exchanging code and data between platforms , or doing direct hardware access . Thus , there are several sets of headers providing platform independent exact width types . The C standard library provides stdint. h ; this was introduced in C99 and C + + 11 . See also ( edit ) Signed number representations Binary - coded decimal , a representation of integers commonly used in mainframe financial applications and in databases Integer overflow C data types Notes ( edit ) Jump up ^ 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 . References ( edit ) Jump up ^ Cheever , Eric . `` Representation of numbers '' . Swarthmore College . Retrieved 2011 - 09 - 11 . Jump up ^ Madhusudhan Konda ( 2011 - 09 - 02 ) . `` A look at Java 7 's new features - O'Reilly Radar '' . Radar.oreilly.com . Retrieved 2013 - 10 - 15 . Jump up ^ `` Sybase Adaptive Server Enterprise 15.5 : Exact Numeric Datatypes '' . Jump up ^ `` MySQL 5.6 Numeric Datatypes '' . Jump up ^ `` BigInteger ( Java Platform SE 6 ) '' . Oracle . Retrieved 2011 - 09 - 11 . ^ Jump up to : Fog , Agner ( 2010 - 02 - 16 ) . `` Calling conventions for different C++ compilers and operating systems : Chapter 3 , Data Representation '' ( PDF ) . Retrieved 2010 - 08 - 30 . Jump up ^ Giguere , Eric ( 1987 - 12 - 18 ) . `` The ANSI Standard : A Summary for the C Programmer '' . Retrieved 2010 - 09 - 04 . ^ Jump up to : Meyers , Randy ( 2000 - 12 - 01 ) . `` The New C : Integers in C99 , Part 1 '' . drdobbs.com . Retrieved 2010 - 09 - 04 . ^ Jump up to : `` ISO / IEC 9899 : 201x '' ( PDF ) . open-std.org . section 6.2. 6.2 , paragraph 2 . Retrieved 2016 - 06 - 20 . ^ Jump up to : `` ISO / IEC 9899 : 201x '' ( PDF ) . open-std.org . section 5.2. 4.2. 1 . Retrieved 2016 - 06 - 20 . Jump up ^ `` Fundamental types in C + + '' . cppreference.com . Retrieved 5 December 2010 . Jump up ^ `` Chapter 8.6. 2 on page 12 '' ( PDF ) . ecma-international.org . Jump up ^ VB 6.0 help file Jump up ^ `` The Integer , Long , and Byte Data Types ( VBA ) '' . microsoft.com . Retrieved 2006 - 12 - 19 . Jump up ^ `` ISO / IEC 9899 : 201x '' ( PDF ) . open-std.org . Retrieved 2013 - 03 - 27 . Jump up ^ Giguere , Eric ( December 18 , 1987 ) . `` The ANSI Standard : A Summary for the C Programmer '' . Retrieved 2010 - 09 - 04 . Jump up ^ `` American National Standard Programming Language C specifies the syntax and semantics of programs written in the C programming language . '' . Retrieved 2010 - 09 - 04 . <Th_colspan="2"> ( hide ) Data types Uninterpreted Bit Byte Trit Tryte Word Bit array Numeric Arbitrary - precision or bignum Complex Decimal Fixed point Floating point Double precision Extended precision Half precision Long double Minifloat Octuple precision Quadruple precision Single precision Integer signedness Interval Rational Pointer Address physical virtual Reference Text Character String null - terminated Composite Algebraic data type generalized Array Associative array Class Dependent Equality Inductive List Object metaobject Option type Product Record Set Union tagged Other Boolean Bottom type Collection Enumerated type Exception Function type Opaque data type Recursive data type Semaphore Stream Top type Type class Unit type Void Related topics Abstract data type Data structure Generic Kind metaclass Parametric polymorphism Primitive data type Protocol interface Subtyping Type constructor Type conversion Type system <Td_colspan="2"> See also platform - dependent and independent units of information Retrieved from `` https://en.wikipedia.org/w/index.php?title=Integer_(computer_science)&oldid=808214908 '' Categories : Data types Computer arithmetic Primitive types Talk Contents About Wikipedia Azərbaycanca Български Català Čeština Dansk Deutsch Eesti Español Euskara فارسی Français 한국어 हिन्दी Bahasa Indonesia Íslenska Italiano Magyar Македонски മലയാളം Nederlands 日本 語 Polski Português Русский Shqip Simple English Svenska Українська Tiếng Việt 中文 Edit links This page was last edited on 1 November 2017 , at 15 : 41 . Text is available under the Creative Commons Attribution - ShareAlike License ; additional terms may apply . By using this site , you agree to the Terms of Use and Privacy Policy . Wikipedia ® is a registered trademark of the Wikimedia Foundation , Inc. , a non-profit organization . About Wikipedia