?? 1076_7.html
字號:
<tr><td><b>Operator</b><td><b>Operation</b><td><b>Operand type</b><td><b>Result type</b></tr>
<tr><td>=<td>Equality<td>Any type<td>BOOLEAN</tr>
<tr><td>/=<td>Inequality<td>Any type<td>BOOLEAN</tr>
<tr><td><<br><=<br>><br>>=<td>Ordering<td>Any scalar type or discrete array type<td>BOOLEAN</tr>
</table>
</center>
<p>The equality and inequality operators (= and /=) are defined for all types other than file types. The equality operator returns the value TRUE if the two operands are equal and returns the value FALSE otherwise. The inequality operator returns the value FALSE if the two operands are equal and returns the value TRUE otherwise.
<p>Two scalar values of the same type are equal if and only if the values are the same. Two composite values of the same type are equal if and only if for each element of the left operand there is a <i>matching</i> <i>element</i> of the right operand and vice versa, and the values of matching elements are equal, as given by the predefined equality operator for the element type. In particular, two null arrays of the same type are always equal. Two values of an access type are equal if and only if they both designate the same object or they both are equal to the null value for the access type.
<p>For two record values, matching elements are those that have the same element identifier. For two one-dimensional array values, matching elements are those (if any) whose index values match in the following sense: the left bounds of the index ranges are defined to match; if two elements match, the elements immediately to their right are also defined to match. For two multi-dimensional array values, matching elements are those whose indices match in successive positions.
<p>The ordering operators are defined for any scalar type and for any discrete array type. A <i>discrete</i> <i>array</i> is a one-dimensional array whose elements are of a discrete type. Each operator returns TRUE if the corresponding relation is satisfied; otherwise, the operator returns FALSE.
<p>For scalar types, ordering is defined in terms of the relative values. For discrete array types, the relation < (less than) is defined such that the left operand is less than the right operand if and only if
<p>-- The left operand is a null array and the right operand is a nonnull array; otherwise,
<p>-- Both operands are nonnull arrays, and one of the following conditions is satisfied:
<p>-- The leftmost element of the left operand is less than that of the right;or
<p>-- The leftmost element of the left operand is equal to that of the right, and the tail of the left operand is less than that of the right (the tail consists of the remaining elements to the right of the leftmost element and can be null).
</ul>
</ul>
<p>The relation <= (less than or equal) for discrete array types is defined to be the inclusive disjunction of the results of the < and = operators for the same two operands. The relations > (greater than) and >= (greater than or equal) are defined to be the complements of the <= and <operators respectively for the same two operands.
<h3><a name="7.2.3"> <a href = "1076_7.HTM#7.2.3"> 7.2.3 </a> Shift operators</a></h3>
<p>The shift operators <b>sll</b>, <b>srl</b>, <b>sla</b>, <b>sra</b>, <b>rol</b>,and <b>ror</b> are defined for any one-dimensional array type whose element type is either of the predefined types BIT or BOOLEAN.<br><br>
<center>
<table border="1">
<tr><td><b>Operator</b><td><b>Operation</b><td><b>Left operand type</b><td><b>Right operand type</b><td><b>Result type</b></tr>
<tr><td><b>sll</b><td>Shift left logical<td>Any one-dimensional array type whose element type is BIT or BOOLEAN<td>INTEGER<td>Same as left</tr>
<tr><td><b>srl</b><td>Shift right logical<td>Any one-dimensional array type whose element typeis BIT or BOOLEAN<td>INTEGER<td>Same as left</tr>
<tr><td><b>sla</b><td>Shift left arithmetic<td>Any one-dimensional array type whose element type is BIT or BOOLEAN<td>INTEGER<td>Same as left</tr>
<tr><td><b>sra</b><td>Shift right arithmetic<td>Any one-dimensional array type whose element type is BIT or BOOLEAN<td>INTEGER<td>Same as left</tr>
<tr><td><b>rol</b><td>Rotate left logical<td>Any one-dimensional array type whose element type is BIT or BOOLEAN<td>INTEGER<td>Same as left</tr>
<tr><td><b>ror</b><td>Rotate right logical<td>Any one-dimensional array type whose element type is BIT or BOOLEAN<td>INTEGER<td>Same as left</tr>
</table>
</center>
<p>
<p>The index subtypes of the return values of all shift operators are the same as the index subtypes of their left arguments.
<p>The values returned by the shift operators are defined as follows. In the remainder of this section, the values of their leftmost arguments are referred to as L and the values of their rightmost arguments are referred to as R.
<p>-- The <b>sll</b> operator returns a value that is L logically shifted left by R index positions. That is, if R is 0 or if L is a null array, the return value is L. Otherwise, a basic shift operation replaces L with a value that is the result of a concatenation whose left argument is the rightmost (L'Length -1) elements of L and whose right argument is T'Left, where T is the element type of L. If R is positive, this basic shift operation is repeated R times to form the result. If R is negative, then the return value is the value of the expression L <b>srl</b> -R.
<p>-- The <b>srl</b> operator returns a value that is L logically shifted right by R index positions. That is, if R is 0 or if L is a null array, the return value is L. Otherwise, a basic shift operation replaces L with a value that is the result of a concatenation whose right argument is the leftmost (L'Length -1) elements of L and whose left argument is T'Left, where T is the element type of L. If R is positive, this basic shift operation is repeated R times to form the result. If R is negative, then the return value is the value of the expression L <b>sll</b> -R.
<p>-- The <b>sla</b> operator returns a value that is L arithmetically shifted left by R index positions. That is, if R is 0 or if L is a null array, the return value is L. Otherwise, a basic shift operation replaces L with a value that is the result of a concatenation whose left argument is the rightmost(L'Length - 1) elements of L and whose right argument is L(L'Right). If R is positive, this basic shift operation is repeated R times to form the result. If R is negative, then the return value is the value of the expression L <b>sra</b> -R.
<p>-- The <b>sra</b> operator returns a value that is L arithmetically shifted right by R index positions. That is, if R is 0 or if L is a null array, the return value is L. Otherwise, a basic shift operation replaces L with a value that is the result of a concatenation whose right argument is the leftmost(L'Length - 1) elements of L and whose left argument is L(L'Left). If R is positive, this basic shift operation is repeated R times to form the result. If R is negative, then the return value is the value of the expression L<b>sla</b> -R.
<p>-- The <b>rol</b> operator returns a value that is L rotated left by R index positions. That is, if R is 0 or if L is a null array, the return value is L. Otherwise, a basic rotate operation replaces L with a value that is the result of a concatenation whose left argument is the rightmost (L'Length - 1) elements of L and whose right argument is L(L'Left). If R is positive, this basic rotate operation is repeated R times to form the result. If R is negative, then the return value is the value of the expression L <b>ror</b> -R.
<p>-- The <b>ror</b> operator returns a value that is L rotated right by R index positions. That is, if R is 0 or if L is a null array, the return value is L. Otherwise, a basic rotate operation replaces L with a value that is the result of a concatenation whose right argument is the leftmost (L'Length - 1) elements of L and whose left argument is L(L'Right). If R is positive, this basic rotate operation is repeated R times to form the result. If R is negative, then the return value is the value of the expression L <b>rol</b> -R.
</ul>
<h4>NOTES</h4>
<p>
<p>1--The logical operators may be overloaded, for example, to disallow negative integers as the second argument.
<p>2--The subtype of the result of a shift operator is the same as that of the left operand.
<h3><a name="7.2.4"> <a href = "1076_7.HTM#7.2.4"> 7.2.4 </a> Adding operators</a></h3>
<p>The adding operators + and - are predefined for any numeric type and have their conventional mathematical meaning. The concatenation operator & is predefined for any one-dimensional array type.<br><br>
<center>
<table border="1">
<tr><td><b>Operator</b><td><b>Operation</b><td><b>Left operand type</b><td><b>Right operand type</b><td><b>Result type</b></tr>
<tr><td>+<td>Addition<td>Any numeric type<td>Same type<td>Same type</tr>
<tr><td>-<td>Subtraction<td>Any numeric type<td>Same type<td>Same type</tr>
<tr><td rowspan="4">&<td rowspan="4">Concatenation<td>Any array type<td>Same array type<td>Same array type</tr>
<tr><td>Any array type<td>The element type<td>Same array type</tr>
<tr><td>The element type<td>Any array type<td>Same array type</tr>
<tr><td>The element type<td>The element type<td>Any array type</tr>
</table>
</center>
<p>
<p>For concatenation, there are three mutually exclusive cases:
<ol type="a">
<li>If both operands are one-dimensional arrays of the same type, the result of the concatenation is a one-dimensional array of this same type whose length is the sum of the lengths of its operands, and whose elements consist of the elements of the left operand (in left-to-right order) followed by the elements of the right operand (in left-to-right order). The direction of the result is the direction of the left operand, unless the left operand is a null array, in which case the direction of the result is that of the right operand.
<ul>
<p>If both operands are null arrays, then the result of the concatenation is the right operand. Otherwise, the direction and bounds of the result are determined as follows: Let S be the index subtype of the base type of the result. The direction of the result of the concatenation is the direction of S, and the left bound of the result is S'LEFT.
</ul>
<p><li>If one of the operands is a one-dimensional array and the type of the other operand is the element type of this aforementioned one-dimensional array, the result of the concatenation is given by the rules in case 1, using in place of the other operand an implicit array having this operand as its only element.
<p><li>If both operands are of the same type and it is the element type of some one-dimensional array type, the type of the result must be known from the context and is this one-dimensional array type. In this case, each operand is treated as the one element of an implicit array, and the result of the concatenation is determined as in case a.
</ol>
<p>In all cases, it is an error if either bound of the index subtype of the result does not belong to the index subtype of the type of the result, unless the result is a null array. It is also an error if any element of the result does not belong to the element subtype of the type of the result.
<p><i>Examples:</i>
<pre> <b>subtype</b> BYTE <b>is</b> BIT_VECTOR (7 <b>downto</b> 0);
<b>type</b> MEMORY <b>is</b> <b>array</b> (Natural <b>range</b> <>) <b>of</b> BYTE;
-- The following concatenation accepts two BIT_VECTORs and returns a BIT_VECTOR
-- (case a):
<b>constant</b> ZERO: BYTE := "0000" & "0000";
-- The next two examples show that the same expression can represent either case a or
-- case c, depending on the context of the expression.
-- The following concatenation accepts two BIT_VECTORS and returns a BIT_VECTOR
-- (case a):
<b>constant</b> C1: BIT_VECTOR := ZERO & ZERO;
-- The following concatenation accepts two BIT_VECTORs and returns a MEMORY
-- (case c):
<b>constant</b> C2: MEMORY := ZERO & ZERO;
-- The following concatenation accepts a BIT_VECTOR and a MEMORY, returning a
-- MEMORY (case b):
<b>constant</b> C3: MEMORY := ZERO & C2;
-- The following concatenation accepts a MEMORY and a BIT_VECTOR, returning a
-- MEMORY (case b):
<b> constant</b> C4: MEMORY := C2 & ZERO;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -