Skip to main content
Engineering LibreTexts

2.7: Data Types

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)


    A data type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support various types of data, including integer, real, character or string, and Boolean.[1]


    Our interactions (inputs and outputs) with a program are treated in many languages as a stream of bytes. These bytes represent data that can be interpreted as representing values that we understand. Additionally, within a program, we process this data in various ways such as adding them up or sorting them. This data comes in different forms. Examples include:

    • your name – a string of characters
    • your age – usually an integer
    • the amount of money in your pocket – usually a value measured in dollars and cents (something with a fractional part)

    A major part of understanding how to design and code programs is centered in understanding the types of data that we want to manipulate and how to manipulate that data.

    Common data types include:

    Data Type Represents Examples
    integer whole numbers -5, 0, 123
    floating point (real) fractional numbers -87.5, 0.0, 3.14159
    string A sequence of characters "Hello world!"
    Boolean logical true or false true, false
    nothing no data null

    The common data types usually exist in most programming languages and act or behave similarly from language to language. Additional complex and/or composite data types may exist and vary from language to language.


    Function Main
        ... This program demonstrates variables, literal constants, and data types.
        Declare Integer i
        Declare Real r
        Declare String s
        Declare Boolean b
        Assign i = 1234567890
        Assign r = 1.23456789012345
        Assign s = "string"
        Assign b = true
        Output "Integer i = " & i
        Output "Real r = " & r
        Output "String s = " & s
        Output "Boolean b = " & b


    Integer i = 1234567890
    Real r = 1.23456789012345
    String s = string
    Boolean b = true



    Key Terms

    A data type representing logical true or false.
    data type
    Defines a set of values and a set of operations that can be applied on those values.
    floating point
    A data type representing numbers with fractional parts.
    A data type representing whole numbers.
    A data type representing a sequence of characters.

    2.7: Data Types is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?