# Integer

> A whole number, like 7, 0 or -12, with nothing after the point.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** int, Whole Number

## Think of it like

Think of it like counting apples. You can have 3 or 4, but not 3 and a bit.

## Definition

An integer is a whole number with no part after the point. 7, 0 and -12 are integers, but 2.5 is not. Programs use integers for counting things, like items in a cart or the number of a page. Maths on integers is exact, so no tiny errors creep in. Most languages call the type int.

## Example

A shop counts 3 books in a cart as the integer 3. Half a book cannot be bought, so a whole number fits.

## Example code

```python
>>> 7 // 2
3
>>> int("12") + 1
13
```

Dividing whole numbers drops the half. And int() turns text into a number.

## Why it matters

Counts, positions and ids are integers. Using the right type keeps the sums exact.

## Common mistake

Expecting 7 divided by 2 to be 3 in every language. Some give 3, some give 3.5, so check which one you have.

## Three principles

- **No fractions.** Only whole numbers, below or above zero.
- **Exact maths.** Adding integers never gives a rounding error.
- **For counting.** Use them for items, pages and ids.

## Related terms

- [Data Type](https://learn.benibix.com/term/development/data-type)
- [Floating-Point Number](https://learn.benibix.com/term/development/floating-point-number)
- [Arithmetic Operator](https://learn.benibix.com/term/development/arithmetic-operator)
- [String](https://learn.benibix.com/term/development/string)

## Told apart from

- [Integer vs Floating-Point Number](https://learn.benibix.com/compare/integer-vs-floating-point-number): People think 3 and 3.0 are the same number to a computer, and they are not. An integer is a whole number, and its sums are exact. A floating-point number has a decimal part, and it keeps a very close value rather than an exact one. That is why 0.1 + 0.2 can give 0.30000000000000004. For money, count in whole cents with integers.

## Taught in

- [Data Types in Python](https://learn.benibix.com/learn/development-concepts/data-types-in-python): Programming Basics, 6/18

---

Source: https://learn.benibix.com/term/development/integer
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
