Value (computer science)
Encyclopedia
In computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, a value (from "fully evaluated") is an expression which cannot be evaluated any further (a normal form). The members of a type are the values of that type. For example, the expression "1 + 2" is not a value as it can be reduced
Reduction (mathematics)
In mathematics, reduction refers to the rewriting of an expression into a simpler form. For example, the process of rewriting a fraction into one with the smallest whole-number denominator possible is called "reducing a fraction"...

 to the expression "3". This expression cannot be reduced any further (and is a member of the type Nat
Natural number
In mathematics, the natural numbers are the ordinary whole numbers used for counting and ordering . These purposes are related to the linguistic notions of cardinal and ordinal numbers, respectively...

) and therefore is a value.

The "value of a variable" is given by the corresponding mapping in the environment. In languages with assignable variables it becomes necessary to distinguish between the R-value (or contents) and the L-value (or location) of a variable.

In declarative (high-level) languages, values have to be referentially transparent. This means that the resulting value is independent of the fact in which location a (sub-)expression needed to compute the value is stored. Only the contents of the location (the bits, whether they are 1 or 0) and their interpretation are significant.

Assignment: l-values and r-values

Some languages use the idea of l-values and r-values. Lvalues are values that have addresses
Memory address
A digital computer's memory, more specifically main memory, consists of many memory locations, each having a memory address, a number, analogous to a street address, at which computer programs store and retrieve, machine code or data. Most application programs do not directly read and write to...

 being programmatically accessible to the running program (e.g., via some address-of–operator like "&" in C/C++), meaning that they are variables or dereferenced references to a certain memory location. Rvalues can be lvalues (see below.) or non-lvalues—a term only used to distinguish from lvalues. In C, the term lvalue originally meant something that could be assigned to (coming from left-value, indicating it was on the left side of the assignment operator), but since 'const' was added to the language, this now is termed a 'modifiable lvalue'.

In C++11 a special semantic-glyph "&&" exists, to denote the use/access of the expression's address for the compiler only, i.e. the address cannot be retrieved using the "&"–address-of–operator during the run-time of the program (see the use of move constructors).
This type of reference can be applied to all r-values including non-lvalues as well as lvalues. Some processors provide one or more instructions which take an "immediate value", sometimes referred to as "immediate" for short. An immediate value is stored as part of the instruction which employs it, usually to load into, add to, or subtract from, a register. The other parts of the instruction are the opcode, and destination. The latter may be implicit. (A non-immediate value may reside in a register, or be stored elsewhere in memory, requiring the instruction to contain a direct or indirect address [e.g. index register address] to the value.)

The lvalue expression designates (refers to) an object. A non-modifiable lvalue is addressable, but not assignable. A modifiable lvalue allows the designated object to be changed as well as examined. An rvalue is any expression, a non-lvalue is any expression that is not an lvalue. One example is an "immediate value" (look below) and consequently not addressable. Another example is the C expression (4 + 9). When executed, the computer generates an integer value of 13, but because the program has not explicitly designated where in the computer this 13 is stored, the expression is an rvalue. On the other hand, if a C program declares a variable x and assigns the value of 13 to x, then the expression (x) has a value of 13 and is an lvalue.

The notion of lvalues and rvalues was introduced by CPL
Combined Programming Language
CPL was a multi-paradigm programming language, that was developed in the early 1960s.- Design :...

.

In assembly language

A value can be virtually any kind of data by a given data type, for instance a string, a digit, a single letter.

Some processors support more than one size of immediate data, e.g. 8 or 16 bit, employing a unique opcode and mnemonic for each instruction variant. If a programmer supplies a data value that will not fit, the assembler issues an "Out of range" error message. Most assemblers allow an immediate value to be expressed as ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

, decimal
Decimal
The decimal numeral system has ten as its base. It is the numerical base most widely used by modern civilizations....

, hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

, octal
Octal
The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7. Numerals can be made from binary numerals by grouping consecutive binary digits into groups of three...

, or binary
Binary
- Mathematics :* Binary numeral system, a representation for numbers using only two digits * Binary function, a function in mathematics that takes two arguments- Computing :* Binary file, composed of something other than human-readable text...

 data. Thus, the ASCII character 'A' is the same as 65 or 0x41. The byte order of strings may differ between processors, depending on the assembler and computer architecture.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK