# Integer

Updated: 12/30/2021 by Computer Hope

An **integer** is a positive or negative whole number. Examples of positive integers are 1, 2, 3, and 4. Examples of **negative integers** are -1, -2, -3, and -4. The number 0 is also considered an integer even though it has neither a positive or negative value. In most programming languages, you can convert a number into an integer using the **int** function.

## The int function in Perl

Below is some code written in the Perl programming language. In the example, the $random variable is assigned a random number, which is then converted into a whole number using the int() function.

my $random = int(rand(10)); print "Random number between 0 and 10: $random\n";

Computer abbreviations, Data type, Factorial, Number, Numeric, Programming terms, String, Whole number