Programming: Data Types

Programming: Data Types

Fundamental Data Types

  • Integer: A whole number that can either be a positive or negative number, including zero.
  • Real or Float: These represent fractional or decimal numbers. They must include a decimal part.
  • Boolean: These can only hold two different values, typically represented as True and False.
  • Character and String: A character is a single letter, number, space, punctuation mark, or symbol. A string is a sequence of characters.
  • Array: A type that can hold multiple values of one data type.

Composite Data Types

  • Record: A data type that allows you to group multiple data values of various types.
  • Enumeration: Data type that allows a variable to be assigned a predefined list of named integer constants.
  • Set: A collection of well-defined objects known as elements.

Dynamic Data Types

  • List: An ordered collection of items which may contain duplicate items.
  • Linked List: A linear collection of data elements, whose order is not given by their physical placement in memory.
  • Queue: A collection in which the entities in the collection are kept in order and the principal operations are the addition of entities to the rear terminal position and removal of entities from the front terminal position.
  • Stack: A collection of elements, with two main operations - push (add an item) and pop (remove an item).

Type Conversion & Casting

  • Type Conversion: The process of changing one data type into another data type in order to perform some operation.
  • Type Casting or Type Coercion: An operations that convert one data type into another. It’s usually done explicitly using the casting operator.
  • Implicit Conversion: Automatic conversion of one data type into another data type by compiler.
  • Explicit Conversion: It’s done by users using a pre-defined function.

Operators and Data Types

Operator types include Arithmetic, Relational, Logical, Bitwise, Assignment operators, which interact with different data types.

  • Math operators like +, -, *, / can work with numeric types like Integer or Float.
  • Equality and comparative operators work with numeric types and sometimes strings depending on the programming language.
  • Logical operators AND, OR, NOT work on Boolean types.
  • The == operator can be used to compare strings for equivalence, but >,<,>=,<= operators cannot.

Null or None Type

  • The term None or Null is a special type that has only one value: None. It signifies the absence of a value or a null value. It is not the same as False, 0, or any empty list, string, etc.

All these data types are fundamental to understanding how programs manage and manipulate data.