Integer

Updated: 12/30/2021 by Computer Hope
Integer one written in blue.

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 Perl programming language code. 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, Decimal, Factorial, Number, Numeric, Programming terms, String, Whole number