# Value

Updated: 08/02/2020 by Computer Hope In mathematics, logic, and computer programming, a value is a definite object. For example, the number 1, the letter a, and the unique combination of letters that forms the word apple are all values.

In a computers, a value is usually a number, a single character, or a string of characters.

## How are values used in computers?

Values help perform calculations and store data. For example, to calculate the sum 1 + 2, the computer must store at least three values: the numbers 1, 2, and 3.

In a digital image, every pixel is a unit of data containing values representing the component colors of the pixel. An image stored in a 24-bit RGB (red, green, and blue) format contains three bytes (24 bits) per pixel. Each of these bytes represents a red, green, or blue color value. Combining these values produces any of 16.7 million unique colors, also known as true color.

### In programming

Values are stored in variables. In math and computer programming, a variable is a named unit of data that can be assigned a value. The value, whatever it may be, can be referred to by that name.

In the following Perl program, there are three variables:

• The variable firstvar is assigned a value of 13.
• The variable secondvar is assigned a value of 48.
• The variable total is assigned the sum of \$firstvar and \$secondvar.
`\$firstvar = 13;\$secondvar = 48;\$total = \$firstvar + \$secondvar;print "The total value is: \$total\n";`

When this program is executed, it displays the following output:

`The total value is: 61`