> 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/primitive-datatypes/integer.md).

# Integer

The integer data type in computer programming is used to represent whole numbers, both positive and negative, without fractions or decimals. Integers are one of the fundamental data types supported by virtually all programming languages, and they are used extensively in various types of calculations, loops, array indexing, and more.

#### Characteristics of the Integer Data Type:

* **Whole Numbers:** Integers include the set of positive whole numbers, negative whole numbers, and zero. For example, -3, 0, and 15 are all integers.
* **No Fractions or Decimals:** Unlike floating-point numbers, integers cannot represent fractions or decimal values.
* **Fixed or Variable Size:** Depending on the programming language and the specific type of integer, they can have a fixed size (such as 32-bit or 64-bit) or vary based on the language's implementation. Fixed-size integers have a minimum and maximum value they can represent, determined by their bit-width.
* **Signed and Unsigned:** Integers can be "signed" (capable of representing both positive and negative values) or "unsigned" (capable of representing only non-negative values). The choice between signed and unsigned integers affects the range of values that can be represented.

#### Usage in Different Programming Languages:

* **C/C++:** Offers several specific types of integers, such as `int`, `short`, `long`, and their unsigned variants like `unsigned int`. The size of these types can vary based on the compiler and platform but is generally consistent within modern systems (e.g., `int` is often 32 bits).
* **Java:** Has fixed-size integer types, including `byte` (8 bits), `short` (16 bits), `int` (32 bits), and `long` (64 bits). By default, integers in Java are signed.
* **Python:** Python's `int` type is flexible and can grow to accommodate any size of integer, limited only by the available memory of the system. This is in contrast to many other languages that have fixed-size integer types.

#### Example Usage:

```c
#include <stdio.h>

int main() {
    int a = 10;
    int b = -5;
    int sum = a + b;

    printf("The sum of a and b is: %d", sum);
    return 0;
}
```

In this C program example, `a` and `b` are integers used in a simple arithmetic operation. The `%d` format specifier in the `printf` function is used to print integer values.


---

# 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/primitive-datatypes/integer.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.
