Value

Updated: 08/02/2020 by Computer Hope
Variable and value

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.

As another example, when you log in to a website, your username is a value sent to the server. The timestamp of your login and your IP address are also values stored by the server in log files.

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

In spreadsheets

In spreadsheet applications such as Microsoft Excel, Google Sheets, or LibreOffice Calc, a cell value is a number or text located in any cell of the spreadsheet. This value may be entered by the user, or may be the result of a formula contained in the cell.

Accuracy, Object, Programming terms