| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>Xor</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- None.
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- Often used for lightweight (meaning worthless ;) encryption, this will take two values and perform an exclusive OR with each bit following the basic rules of XOR. The result can be XORed with one of the original numbers to reveal the other number. See the example for more.
- <br>
- <br>
- See also: <a class=small href=And.htm>And</a>, <a class=small href=Or.htm>Or</a>, <a class=small href=Not.htm>Not</a>.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/Xor.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- num=%11110000111100001111000011110000 ; Define a bit pattern which is easy to recognize
<br />
-
<br />
- bitmask=Rnd(-2147483648,2147483647) ; Define a RANDOM Xor 32bit wide bitmask
<br />
-
<br />
- ; This line prints the binary and decimal numbers before the Xor
<br />
- Print "Binary number is: "+Bin$(num)+" ("+num+")"
<br />
-
<br />
- ; This line prints the binary and decimal numbers of the Xor bitmask
<br />
- Print "Xor bitmask is: "+Bin$(bitmask)+" ("+bitmask+")"
<br />
-
<br />
- Print "------------------------------------------------------------------"
<br />
-
<br />
- ; This line Xor's the number with the bitmask
<br />
- xres=num Xor bitmask
<br />
-
<br />
- ; This line prints the binary and decimal numbers after the Xor
<br />
- Print "Xor result is: "+Bin$(xres)+" ("+xres+")"
<br />
- Print "------------------------------------------------------------------"
<br />
-
<br />
- ; This line Xor's the Xor result with the bitmask again
<br />
- xres=xres Xor bitmask
<br />
- ; This line prints the binary and decimal numbers after the second Xor. NOTE: This number is identical to the original number
<br />
- Print "Result Xor'ed again: "+Bin$(xres)+" ("+xres+")"
<br />
-
<br />
- WaitMouse ; Wait for the mouse before ending.
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Xor&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|