15.07.2010, 05:37
Quote:
• Bit manipulation ~ ~e results in the one’s complement of e. >> e1 >> e2 results in the arithmetic shift to the right of e1 by e2 bits. The shift operation is signed: the leftmost bit of e1 is copied to vacant bits in the result. Operators and expressions 107 >>> e1 >>> e2 results in the logical shift to the right of e1 by e2 bits. The shift operation is unsigned: the vacant bits of the result are filled with zeros. << e1 << e2 results in the value of e1 shifted to the left by e2 bits; the rightmost bits are set to zero. There is no distinction between an arithmetic and a logical left shift & e1 & e2 results in the bitwise logical “and” of e1 and e2. | e1 | e2 results in the bitwise logical “or” of e1 and e2. ^ e1 ^ e2 results in the bitwise “exclusive or” of e1 and e2. • Assignment The result of an assignment expression is the value of the left operand after the assignment. The left operand may not be tagged. Tag names: 67 = v = e assigns the value of e to variable v. = v = a assigns array a to variable v; v must be an array with the same size and dimensions as a; a may be a string or a literal array. Note: the following operators combine an assignment with an arithmetic or a bitwise operation; the result of the expression is the value of the left operand after the arithmetic or bitwise operation. += v += e increments v with e. -= v -= e decrements v with e 108 Operators and expressions *= v *= e multiplies v with e /= v /= e divides v by e. %= v %= e assigns the remainder of the division of v by e to v. >>= v >>= e shifts v arithmetically to the right by e bits. >>>= v >>>= e shifts v logically to the right by e bits. <<= v <<= e shifts v to the left by e bits. &= v &= e applies a bitwise “and” to v and e and assigns the result to v. |= v |= e applies a bitwise “or” to v and e and assigns the result to v. ^= v ^= e applies a bitwise “exclusive or” to v and e and assigns the result to v. • Relational A logical “false” is represented by an integer value of 0; a logical “true” is represented by any value other than 0. Value results of relational expressions are either 0 or 1, and their tag is set to “bool:”. == e1 == e2 results in a logical “true” if e1 is equal to e2. != e1 != e2 results in a logical “true” if e1 differs from e2. Note: the following operators may be “chained”, as in the expression “e1 <= e2 <= e3”, with the semantics that the result is “1” if all individual comparisons hold and “0” otherwise. < e1 < e2 results in a logical “true” if e1 is smaller than e2. Operators and expressions 109 <= e1 <= e2 results in a logical “true” if e1 is smaller than or equal to e2. > e1 > e2 results in a logical “true” if e1 is greater than e2. >= e1 >= e2 results in a logical “true” if e1 is greater than or equal to e2. • Boolean A logical “false” is represented by an integer value of 0; a logical “true” is represented by any value other than 0. Value results of Boolean expressions are either 0 or 1, and their tag is set to “bool”. ! !e results to a logical “true” if e was logically “false”. || e1 || e2 results to a logical “true” if either e1 or e2 (or both) are logically “true”. The expression e2 is only evaluated if e1 is logically “false”. && e1 && e2 results to a logical “true” if both e1 and e2 are logically “true”. The expression e2 is only evaluated if e1 is logically “true”. |