Skip to content

Integer

In one line

An integer is a whole number — positive, negative, or zero — with no fractional or decimal part.

In simple words

An integer is a number without a decimal point. Examples include 5, -3, 0, 42, and -1000. Integers are used for counting, indexing, and any situation where fractional values do not make sense.

Most languages distinguish integers from floating-point numbers (floats), which have decimal parts. For example, 7 is an integer, but 7.5 is a float. In JavaScript, all numbers are technically floats, but in languages like Python, Java, and C, integers and floats are distinct types.

Integers are efficient for the computer to store and calculate with. They are the default choice for loop counters, array indices, and anything you count or enumerate.

Example

python
age = 25          # integer
temperature = -5  # negative integer

print(type(age))  # <class 'int'>
print(7 / 2)      # 3.5 (float, not integer)
print(7 // 2)     # 3  (integer division)

In Python, int is a distinct type. Integer division // discards the fractional part.

Common confusions

  • Confused with: float

    The difference: An integer is a whole number with no decimal part (7); a float has a fractional part (7.5). Operations like 7/2 may produce a float even from integer inputs.

Related terms

Related Resources

Related Lessons

  • Data Types

    Integers are covered as a core data type

Learn the fundamentals

Deepen your understanding with structured lessons on this topic.

View lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary