Contents 1 Concept 2 Definition 3 Classes of data types 3.1 Primitive data types 3.1.1 Machine data types 3.1.2 Boolean type 3.1.3 Numeric types 3.2 Composite types 3.2.1 Enumerations 3.2.2 String and text types 3.3 Other types 3.3.1 Pointers and references 3.3.2 Function types 3.4 Abstract data types 3.5 Utility types 4 Type systems 5 See also 6 References 7 Further reading


Concept[edit] Data types are used within type systems, which offer various ways of defining, implementing and using them. Different type systems ensure varying degrees of type safety. Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. Common data types include: integers booleans characters floating-point numbers alphanumeric strings For example, in the Java programming language, the type int represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, as well as the operations that can be performed on integers, such as addition, subtraction, and multiplication. Colors, on the other hand, are represented by three bytes denoting the amounts each of red, green, and blue, and one string representing that color's name; allowable operations include addition and subtraction, but not multiplication. Most programming languages also allow the programmer to define additional data types, usually by combining multiple elements of other types and defining the valid operations of the new data type. For example, a programmer might create a new data type named "complex number" that would include real and imaginary parts. A data type also represents a constraint placed upon the interpretation of data in a type system, describing representation, interpretation and structure of values or objects stored in computer memory. The type system uses data type information to check correctness of computer programs that access or manipulate the data. Most data types in statistics have comparable types in computer programming, and vice versa, as shown in the following table: Statistics Programming real-valued (interval scale) floating-point real-valued (ratio scale) count data (usually non-negative) integer binary data Boolean categorical data enumerated type random vector list or array random matrix two-dimensional array random tree tree


Definition[edit] (Parnas, Shore & Weiss 1976) identified five definitions of a "type" that were used—sometimes implicitly—in the literature. Types including behavior align more closely with object-oriented models, whereas a structured programming model would tend to not include code, and are called plain old data structures. The five types are: Syntactic A type is a purely syntactic label associated with a variable when it is declared. Such definitions of "type" do not give any semantic meaning to types.[clarification needed] Representation A type is defined in terms of its composition of more primitive types—often machine types. Representation and behaviour A type is defined as its representation and a set of operators manipulating these representations. Value space A type is a set of possible values which a variable can possess. Such definitions make it possible to speak about (disjoint) unions or Cartesian products of types. Value space and behaviour A type is a set of values which a variable can possess and a set of functions that one can apply to these values. The definition in terms of a representation was often done in imperative languages such as ALGOL and Pascal, while the definition in terms of a value space and behaviour was used in higher-level languages such as Simula and CLU.


Classes of data types[edit] Primitive data types[edit] Primitive data types are typically types that are built-in or basic to a language implementation. Machine data types[edit] All data in computers based on digital electronics is represented as bits (alternatives 0 and 1) on the lowest level. The smallest addressable unit of data is usually a group of bits called a byte (usually an octet, which is 8 bits). The unit processed by machine code instructions is called a word (as of 2011, typically 32 or 64 bits). Most instructions interpret the word as a binary number, such that a 32-bit word can represent unsigned integer values from 0 to 2 32 − 1 {\displaystyle 2^{32}-1} or signed integer values from − 2 31 {\displaystyle -2^{31}} to 2 31 − 1 {\displaystyle 2^{31}-1} . Because of two's complement, the machine language and machine doesn't need to distinguish between these unsigned and signed data types for the most part. There is a specific set[which?] of arithmetic instructions that use a different[clarification needed] interpretation of the bits in word as a floating-point number. Machine data types need to be exposed or made available in systems or low-level programming languages, allowing fine-grained control over hardware. The C programming language, for instance, supplies integer types of various widths, such as short and long. If a corresponding native type does not exist on the target platform, the compiler will break them down into code using types that do exist. For instance, if a 32-bit integer is requested on a 16 bit platform, the compiler will tacitly treat it as an array of two 16 bit integers. Several languages allow binary and hexadecimal literals, for convenient manipulation of machine data. In higher level programming, machine data types are often hidden or abstracted as an implementation detail that would render code less portable if exposed. For instance, a generic numeric type might be supplied instead of integers of some specific bit-width. Boolean type[edit] The Boolean type represents the values true and false. Although only two values are possible, they are rarely implemented as a single binary digit for efficiency reasons. Many programming languages do not have an explicit Boolean type, instead interpreting (for instance) 0 as false and other values as true. Boolean data simply refers to the logical structure of how the language is interpreted to the machine language. In this case a Boolean 0 refers to the logic False. True is always a non zero, especially a one which is known as Boolean 1. Numeric types[edit] Such as: The integer data types, or "non-fractional numbers". May be sub-typed according to their ability to contain negative values (e.g. unsigned in C and C++). May also have a small number of predefined subtypes (such as short and long in C/C++); or allow users to freely define subranges such as 1..12 (e.g. Pascal/Ada). Floating point data types, usually represent values as high-precision fractional values (rational numbers, mathematically), but are sometimes misleadingly called reals (evocative of mathematical real numbers). They usually have predefined limits on both their maximum values and their precision. Output of these values are often represented in a decimal number format. Fixed point data types are convenient for representing monetary values. They are often implemented internally as integers, leading to predefined limits. Bignum or arbitrary precision numeric types lack predefined limits. They are not primitive types, and are used sparingly for efficiency reasons. Composite types[edit] Composite types are derived from more than one primitive type. This can be done in a number of ways. The ways they are combined are called data structures. Composing a primitive type into a compound type generally results in a new type, e.g. array-of-integer is a different type to integer. An array stores a number of elements of the same type in a specific order. They are accessed randomly using an integer to specify which element is required (although the elements may be of almost any type). Arrays may be fixed-length or expandable. A list is similar to an array, but its contents are strung together by a series of references to the next element. Record (also called tuple or struct) Records are among the simplest data structures. A record is a value that contains other values, typically in fixed number and sequence and typically indexed by names. The elements of records are usually called fields or members. Union. A union type definition will specify which of a number of permitted primitive types may be stored in its instances, e.g. "float or long integer". Contrast with a record, which could be defined to contain a float and an integer; whereas, in a union, there is only one type allowed at a time. A tagged union (also called a variant, variant record, discriminated union, or disjoint union) contains an additional field indicating its current type for enhanced type safety. A set is an abstract data structure that can store certain values, without any particular order, and no repeated values. Values themselves are not retrieved from sets, rather one tests a value for membership to obtain a boolean "in" or "not in". An object contains a number of data fields, like a record, and also a number of subroutines for accessing or modifying them, called methods. Many others are possible, but they tend to be further variations and compounds of the above. Enumerations[edit] The enumerated type has distinct values, which can be compared and assigned, but which do not necessarily have any particular concrete representation in the computer's memory; compilers and interpreters can represent them arbitrarily. For example, the four suits in a deck of playing cards may be four enumerators named CLUB, DIAMOND, HEART, SPADE, belonging to an enumerated type named suit. If a variable V is declared having suit as its data type, one can assign any of those four values to it. Some implementations allow programmers to assign integer values to the enumeration values, or even treat them as type-equivalent to integers. String and text types[edit] Such as: Alphanumeric character. A letter of the alphabet, digit, blank space, punctuation mark, etc. Alphanumeric strings, a sequence of characters. They are typically used to represent words and text. Character and string types can store sequences of characters from a character set such as ASCII. Since most character sets include the digits, it is possible to have a numeric string, such as "1234". However, many languages treat these as belonging to a different type to the numeric value 1234. Character and string types can have different subtypes according to the required character "width". The original 7-bit wide ASCII was found to be limited, and superseded by 8 and 16-bit sets, which can encode a wide variety of non-Latin alphabets (Hebrew, Chinese) and other symbols. Strings may be either stretch-to-fit or of fixed size, even in the same programming language. They may also be subtyped by their maximum size. Note: strings are not primitive in all languages, for instance C: they may be composed from arrays of characters. Other types[edit] Types can be based on, or derived from, the basic types explained above. In some languages, such as C, functions have a type derived from the type of their return value. Pointers and references[edit] The main non-composite, derived type is the pointer, a data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address. It is a primitive kind of reference. (In everyday terms, a page number in a book could be considered a piece of data that refers to another one). Pointers are often stored in a format similar to an integer; however, attempting to dereference or "look up" a pointer whose value was never a valid memory address would cause a program to crash. To ameliorate this potential problem, pointers are considered a separate type to the type of data they point to, even if the underlying representation is the same. Function types[edit] Main article: Function type This section needs expansion. You can help by adding to it. (October 2012) Abstract data types[edit] Any type that does not specify an implementation is an abstract data type. For instance, a stack (which is an abstract type) can be implemented as an array (a contiguous block of memory containing multiple values), or as a linked list (a set of non-contiguous memory blocks linked by pointers). Abstract types can be handled by code that does not know or "care" what underlying types are contained in them. Programming that is agnostic about concrete data types is called generic programming. Arrays and records can also contain underlying types, but are considered concrete because they specify how their contents or elements are laid out in memory. Examples include: A queue is a first-in first-out list. Variations are Deque and Priority queue. A set can store certain values, without any particular order, and with no repeated values. A stack is a last-in, first out data structure. A tree is a hierarchical structure. A graph. A hash, dictionary, map or associative array is a more flexible variation on a record, in which name-value pairs can be added and deleted freely. A smart pointer is the abstract counterpart to a pointer. Both are kinds of references. Utility types[edit] For convenience, high-level languages may supply ready-made "real world" data types, for instance times, dates and monetary values and memory, even where the language allows them to be built from primitive types.


Type systems[edit] A type system associates types with computed values. By examining the flow of these values, a type system attempts to prove that no type errors can occur. The type system in question determines what constitutes a type error, but a type system generally seeks to guarantee that operations expecting a certain kind of value are not used with values for which that operation does not make sense. A compiler may use the static type of a value to optimize the storage it needs and the choice of algorithms for operations on the value. In many C compilers the float data type, for example, is represented in 32 bits, in accord with the IEEE specification for single-precision floating point numbers. They will thus use floating-point-specific microprocessor operations on those values (floating-point addition, multiplication, etc.). The depth of type constraints and the manner of their evaluation affect the typing of the language. A programming language may further associate an operation with varying concrete algorithms on each type in the case of type polymorphism. Type theory is the study of type systems, although the concrete type systems of programming languages originate from practical issues of computer architecture, compiler implementation, and language design. Type systems may be variously static or dynamic, strong or weak typing, and so forth.


See also[edit] C data types Data dictionary Functional programming Kind Type theory for the mathematical models of types Type system for different choices in programming language typing


References[edit] ^ type at the Free On-line Dictionary of Computing ^ Shaffer, C.A. Data Structures and Algorithms, 1.2


Further reading[edit] Parnas, David L.; Shore, John E.; Weiss, David (1976). "Abstract types defined as classes of variables". Proceedings of the 1976 conference on Data : Abstraction, definition and structure: 149–154. doi:10.1145/800237.807133.  Cardelli, Luca; Wegner, Peter (December 1985). "On Understanding Types, Data Abstraction, and Polymorphism" (PDF). ACM Computing Surveys. New York, NY, USA: ACM. 17 (4): 471–523. doi:10.1145/6041.6042. ISSN 0360-0300.  Cleaveland, J. Craig (1986). An Introduction to Data Types. Addison-Wesley. ISBN 0201119404.  v t e 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 Type theory See also platform-dependent and independent units of information Authority control GND: 4011149-0 Retrieved from "https://en.wikipedia.org/w/index.php?title=Data_type&oldid=825989791" Categories: Data typesProgramming language conceptsHidden categories: Wikipedia articles needing clarification from August 2016All articles with specifically marked weasel-worded phrasesArticles with specifically marked weasel-worded phrases from August 2016Articles to be expanded from October 2012All articles to be expandedArticles using small message boxesArticles with example C codeWikipedia articles with GND identifiers


Navigation menu Personal tools Not logged inTalkContributionsCreate accountLog in Namespaces ArticleTalk Variants Views ReadEditView history More Search Navigation Main pageContentsFeatured contentCurrent eventsRandom articleDonate to WikipediaWikipedia store Interaction HelpAbout WikipediaCommunity portalRecent changesContact page Tools What links hereRelated changesUpload fileSpecial pagesPermanent linkPage informationWikidata itemCite this page Print/export Create a bookDownload as PDFPrintable version In other projects Wikimedia Commons Languages العربيةAsturianuAzərbaycancaBân-lâm-gúБеларуская (тарашкевіца)‎БългарскиCatalàČeštinaDanskDeutschEestiΕλληνικάEspañolEsperantoفارسیFrançais한국어ÍslenskaItalianoעבריתҚазақшаLatviešuLietuviųMagyarBahasa MelayuNederlands日本語NorskPolskiPortuguêsRomânăРусскийSimple EnglishSlovenčinaSlovenščinaСрпски / srpskiSvenskaதமிழ்తెలుగుTürkçeУкраїнськаTiếng Việt中文 Edit links This page was last edited on 16 February 2018, at 15:46. 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. Privacy policy About Wikipedia Disclaimers Contact Wikipedia Developers Cookie statement Mobile view (window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgPageParseReport":{"limitreport":{"cputime":"0.192","walltime":"0.507","ppvisitednodes":{"value":1048,"limit":1000000},"ppgeneratednodes":{"value":0,"limit":1500000},"postexpandincludesize":{"value":33559,"limit":2097152},"templateargumentsize":{"value":1688,"limit":2097152},"expansiondepth":{"value":11,"limit":40},"expensivefunctioncount":{"value":3,"limit":500},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 206.173 1 -total"," 27.35% 56.380 2 Template:Clarify"," 24.85% 51.244 2 Template:Fix-span"," 17.59% 36.271 2 Template:Cite_journal"," 15.37% 31.696 5 Template:Category_handler"," 10.56% 21.772 3 Template:Delink"," 10.35% 21.347 1 Template:Authority_control"," 9.14% 18.849 2 Template:Replace"," 8.24% 16.996 1 Template:Harv"," 7.58% 15.626 1 Template:Which"]},"scribunto":{"limitreport-timeusage":{"value":"0.093","limit":"10.000"},"limitreport-memusage":{"value":3102980,"limit":52428800}},"cachereport":{"origin":"mw1321","timestamp":"20180217193704","ttl":1900800,"transientcontent":false}}});});(window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgBackendResponseTime":613,"wgHostname":"mw1321"});});


Data_type - Photos and All Basic Informations

Data_type More Links

Computer ScienceComputer ProgrammingCompilerInterpreter (computing)Real NumberInteger (computer Science)Boolean Data TypeExpression (computer Science)Type SafetyInteger (computer Science)Boolean Data TypeCharacter (computing)Floating PointString (computer Science)Java (programming Language)32-bitInteger (computer Science)ByteComplex NumberType SystemValue (computer Science)Object (computer Science)Correctness Of Computer ProgramsReal-valuedInterval ScaleFloating-pointReal-valuedRatio ScaleCount DataInteger (computer Science)Binary DataBoolean Data TypeCategorical DataEnumerated TypeRandom VectorList (abstract Data Type)Array Data TypeRandom MatrixArray Data TypeRandom Tree (disambiguation)Tree (data Structure)Object-orientedStructured ProgrammingPlain Old Data StructureSyntaxVariable (computer Science)SemanticWikipedia:Please ClarifyOperator (computer Programming)Disjoint UnionUnion (set Theory)Cartesian ProductFunction (computer Science)ALGOLPascal (programming Language)SimulaCLU (programming Language)Primitive Data TypeBitByteOctet (computing)Machine CodeWord (data Type)Binary NumberTwo's ComplementWikipedia:Avoid Weasel WordsWikipedia:Please ClarifyFloating-pointSystems ProgrammingLow-level Programming LanguageC Programming LanguageBinary Numeral SystemHexadecimalLiteral (computer Science)Boolean TypeLogical TruthFalse (logic)Integer (computing)Pascal (programming Language)Ada (programming Language)Floating PointRational NumbersReal NumbersDecimal NumberFixed Point (computing)BignumArbitrary PrecisionComposite TypeData StructureArray Data TypeList (abstract Data Type)Record (computer Science)Data StructureUnion (computer Science)Record (computer Science)Tagged UnionVariant TypeSet (abstract Data Type)Abstract Data StructureSequenceObject (computer Science)Method (computer Programming)Enumerated TypeAlphanumericCharacter (computing)AlphabetString (computer Science)ASCIINumerical DigitHebrewChinese LanguageFunction (computer Science)Return ValuePointer (computer Programming)Computer MemoryMemory AddressReference (computer Science)Function TypeEdit Section: Abstract Data TypesAbstract Data TypeStack (abstract Data Type)Linked ListPointer (computer Science)Generic ProgrammingQueue (data Structure)DequePriority QueueSet (computer Science)SequenceStack (data Structure)Tree (computer Science)Hierarchical StructureGraph (data Structure)Hash TableMap (computer Science)Associative ArrayName-value PairSmart PointerReference (computer Science)Type SystemCompilerC (programming Language)BitIEEE 754-2008Instruction SetProgramming LanguageType PolymorphismType TheoryStatic TypingDynamic TypingStrong TypingWeak TypingC Data TypesData DictionaryFunctional ProgrammingKind (type Theory)Type TheoryType SystemFree On-line Dictionary Of ComputingDavid ParnasDigital Object IdentifierLuca CardelliPeter WegnerACM Computing SurveysAssociation For Computing MachineryDigital Object IdentifierInternational Standard Serial NumberInternational Standard Book NumberSpecial:BookSources/0201119404Template:Data TypesTemplate Talk:Data TypesUnits Of InformationBitByteTernary Numeral SystemTernary Numeral SystemWord (computer Architecture)Bit ArrayArbitrary-precision ArithmeticComplex Data TypeDecimal Data TypeFixed-point ArithmeticFloating PointDouble-precision Floating-point FormatExtended PrecisionHalf-precision Floating-point FormatLong DoubleMinifloatOctuple-precision Floating-point FormatQuadruple-precision Floating-point FormatSingle-precision Floating-point FormatInteger (computer Science)SignednessInterval ArithmeticRational Data TypePointer (computer Programming)Memory AddressPhysical AddressVirtual Address SpaceReference (computer Science)Plain TextCharacter (computing)String (computer Science)Null-terminated StringComposite Data TypeAlgebraic Data TypeGeneralized Algebraic Data TypeArray Data TypeAssociative ArrayClass (computer Programming)Dependent TypeIntuitionistic Type TheoryInductive TypeList (abstract Data Type)Object (computer Science)MetaobjectOption TypeProduct TypeRecord (computer Science)Set (abstract Data Type)Union TypeTagged UnionBoolean Data TypeBottom TypeContainer (abstract Data Type)Enumerated TypeException HandlingFunction TypeOpaque Data TypeRecursive Data TypeSemaphore (programming)Stream (computing)Top TypeType ClassUnit TypeVoid TypeAbstract Data TypeData StructureGeneric ProgrammingKind (type Theory)MetaclassParametric PolymorphismPrimitive Data TypeProtocol (object-oriented Programming)Interface (computing)SubtypingType ConstructorType ConversionType SystemType TheoryTemplate:Information UnitsHelp:Authority ControlIntegrated Authority FileHelp:CategoryCategory:Data TypesCategory:Programming Language ConceptsCategory:Wikipedia Articles Needing Clarification From August 2016Category:All Articles With Specifically Marked Weasel-worded PhrasesCategory:Articles With Specifically Marked Weasel-worded Phrases From August 2016Category:Articles To Be Expanded From October 2012Category:All Articles To Be ExpandedCategory:Articles Using Small Message BoxesCategory:Articles With Example C CodeCategory:Wikipedia Articles With GND IdentifiersDiscussion About Edits From This IP Address [n]A List Of Edits Made From This IP Address [y]View The Content Page [c]Discussion About The Content Page [t]Edit This Page [e]Visit The Main Page [z]Guides To Browsing WikipediaFeatured Content – The Best Of WikipediaFind Background Information On Current EventsLoad A Random Article [x]Guidance On How To Use And Edit WikipediaFind Out About WikipediaAbout The Project, What You Can Do, Where To Find ThingsA List Of Recent Changes In The Wiki [r]List Of All English Wikipedia Pages Containing Links To This Page [j]Recent Changes In Pages Linked From This Page [k]Upload Files [u]A List Of All Special Pages [q]Wikipedia:AboutWikipedia:General Disclaimer



view link view link view link view link view link