cvs: phpdoc /en/language operators.xml

From: Date: Mon, 13 Apr 2009 03:54:14 +0000
Subject: cvs: phpdoc /en/language operators.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-3691@lists.php.net to get a copy of this message
danielc Mon Apr 13 03:54:14 2009 UTC Modified files: /phpdoc/en/language operators.xml Log: * Bitwise: add explanations of how things work, including arithmetic shifting, precedence and data types. http://cvs.php.net/viewvc.cgi/phpdoc/en/language/operators.xml?r1=1.137&r2=1.138&diff_format=u Index: phpdoc/en/language/operators.xml diff -u phpdoc/en/language/operators.xml:1.137 phpdoc/en/language/operators.xml:1.138 --- phpdoc/en/language/operators.xml:1.137 Mon Apr 6 20:46:30 2009 +++ phpdoc/en/language/operators.xml Mon Apr 13 03:54:14 2009 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.137 $ --> +<!-- $Revision: 1.138 $ --> <chapter xml:id="language.operators" xmlns="http://docbook.org/ns/docbook"> <title>Operators</title> <simpara> @@ -375,10 +375,8 @@ <sect1 xml:id="language.operators.bitwise"> <title>Bitwise Operators</title> <simpara> - Bitwise operators allow you to turn specific bits within an - integer on or off. If both the left- and right-hand parameters are - strings, the bitwise operator will operate on the characters' ASCII - values. + Bitwise operators allow evaluation and manipulation of specific + bits within an integer. </simpara> <table> <title>Bitwise Operators</title> @@ -435,6 +433,31 @@ </tgroup> </table> <para> + Bit shifting in PHP is arithmetic. + Bits shifted off either end are discarded. + Left shifts have zeros shifted in on the right while the sign + bit is shifted out on the left, meaning the sign of an operand + is not preserved. + Right shifts have copies of the sign bit shifted in on the left, + meaning the sign of an operand is preserved. + </para> + + <para> + Use parentheses to ensure the desired + <link linkend="language.operators.precedence">precedence</link>. + For example, <userinput>$a & $b == true</userinput> evaluates + the equivalency then the bitwise and; while + <userinput>($a & $b) == true</userinput> evaluates the bitwise and + then the equivalency. + </para> + + <para> + Be aware of data type conversions. If both the left-hand and + right-hand parameters are strings, the bitwise operator will + operate on the characters' ASCII values. + </para> + + <para> <example> <title>Bitwise AND, OR and XOR operations on integers</title> <programlisting role="php">

« previous php.doc.cvs (#3691) next »