> For the complete documentation index, see [llms.txt](https://university-west.gitbook.io/programming-paradigms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/datatypes.md).

# Datatypes

Datatypes in computer programming are classifications that specify the type of data that a variable or object can hold. They define the operations that can be performed on the data, the way it is stored, and the range of values it can take.

**Purpose of Datatypes:**

1. **Data Interpretation:** Datatypes tell the computer how to interpret a piece of data. For instance, whether to treat data as a number, a character, a decimal, or something else.
2. **Memory Allocation:** They help in allocating appropriate memory size for the data stored. Different datatypes require different amounts of memory.
3. **Operation Definition:** Datatypes determine the type of operations that can be performed on the data. For example, arithmetic operations are suitable for numeric types but not for boolean types.
4. **Data Integrity:** By defining the type of data, datatypes ensure that operations on variables are logically correct. For instance, preventing the addition of a number and a text string.
5. **Type Checking:** Datatypes enable compilers and interpreters to check for type-related errors in the code, improving code reliability.

**Common Categories of Datatypes:**

1. **Primitive Datatypes:** These are the most basic datatypes that are built into a programming language. They typically include:
   * **Integer:** Whole numbers, both positive and negative.
   * **Floating Point:** Numbers with a fractional part usually named float, double, etc.
   * **Character:** Individual characters like letters, numbers, and symbols.
   * **Boolean:** True or False values.
2. **Composite Datatypes:** These are more complex datatypes that are made up of primitive datatypes and other composite types. They include:
   * **Arrays:** Collections of elements, all of the same type.
   * **Structures (Structs):** Collections of elements of different types.
   * **Classes:** The basis of objects in object-oriented programming, encapsulating data and operations.
3. **Specialized Datatypes:**
   * **Pointers:** Used to store memory addresses.
   * **Enums:** A set of named constant values.
4. **Derived Datatypes:** These are types derived from primitive or composite types. They include:
   * **Lists:** Similar to arrays but can grow dynamically.
   * **Queues, Stacks, Trees, Graphs:** Used for specific data organization and manipulation techniques.

**Language-Specific Variations:**

* Different programming languages have different ways of defining and handling datatypes. For instance, in strongly typed languages like Java or C#, datatypes must be explicitly specified, while in dynamically typed languages like Python, datatypes are inferred at runtime.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/datatypes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
