Whole number

Updated: 04/26/2017 by Computer Hope

A whole number is any number that does not contain a fraction, decimal, or negative value. For example, 1, 25, and 365 are whole numbers. Whereas the values of -3, 100.01, 365 ¼, and 2006.3 are not.

In most programming languages, you can convert a number into a whole number by making it an integer. The following example shows how this could be done in Perl. The expression starts with $random, a variable assigned a random number. That random value 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";

Floating-point, Integer, Number, Programming terms