Sponsored Content
Full Discussion: Analysis in bitwise XOR
Top Forums UNIX for Beginners Questions & Answers Answers to Frequently Asked Questions FAQ Submission Queue Analysis in bitwise XOR Post 302608273 by Corona688 on Friday 16th of March 2012 06:11:07 PM
Old 03-16-2012
You are getting a number of things mixed up together and confused.

Quote:
In general, if the operands are in the form of n ^ (n+1) and also n is an even number, then the result is always 1.
xor can be considered a form of comparison, too. What bit is going to change when you add 1 to an even number? The last bit, of course, the 1 bit. This isn't so mysterious or strange.

Your perl examples don't work because they contain syntax errors, logic errors, and you typed them in MS Word, which destroys all code by inserting smart quotes. But perl does, to my surprise, do what you say:

Code:
perl -e "print 'asdf' ^ 'asdf';" | hexdump -C
00000000  00 00 00 00                                       |....|
00000004

 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

bitwise operators

can anybody write a program to divide a number by another number using bitwise operators (9 Replies)
Discussion started by: areef4u
9 Replies

2. Programming

resetting counter using bitwise XOR

Hi ! How to reset a variable to 0 after a reset value, say 10 using bitwise XOR. For example, int cnt=0; if(cnt<10) cnt++; else cnt = 0; How can we achieve this by using XOR only. thanks, (1 Reply)
Discussion started by: mrgubbala
1 Replies

3. Shell Programming and Scripting

xor 2 values in ksh?

i have to xor two variables in ksh. how to do that? tia, DN2 (5 Replies)
Discussion started by: DukeNuke2
5 Replies

4. Shell Programming and Scripting

Bitwise negation

I am taking an online course on Unix scripting. The topic is Unix arithmetic operators and the lesson is Logical and bitwise operations. It is not clear how much storage space Unix uses to represent integers that are typed. Bitwise negation caused me to question how many bits are used to... (3 Replies)
Discussion started by: dLloydm
3 Replies

5. Programming

bitwise and if

Hi Suppose we have these code lines: #define _IN_USE 0x001 /* set when process slot is in use */ #define _EXITING 0x002 /* set when exit is expected */ #define _REFRESHING 0x004 ... 1 main () { 2 3 unsigned r_flags =_REFRESHING; 4 5 if (r_flag &... (3 Replies)
Discussion started by: Puntino
3 Replies

6. Programming

A trivial XOR doubt in a program

Hi, I am trying to reverse a string using the following program utilizing the Exclusive OR bit operation: int main() { char str = "Quraish"; char *p = str, temp; char *q = str + strlen(str) - 1; while ( p != q ) { if (*p != *q) { *p ^= *q; *q ^= *p; *p ^= *q;... (1 Reply)
Discussion started by: royalibrahim
1 Replies

7. Emergency UNIX and Linux Support

bitwise and between two 32 bit binaries

Hello All, i have two 16 bit binaries that in two different variables, i want to perform a bitwise AND between the two and store the result in a different variable. can anyone throw some light on doing this in a bourne shell... eg var1= 1110101010101011 ... (8 Replies)
Discussion started by: venu
8 Replies

8. UNIX for Dummies Questions & Answers

XOR between strings

I am aware of truth table for XOR between binary values . Out of curious in would like to know how XOR works between 2 strings which contain alphabets . For example A ^ B How it works internally? Please help me to understand this Thanks (1 Reply)
Discussion started by: pandeesh
1 Replies

9. UNIX for Dummies Questions & Answers

XOR two strings

hi, i am new to shell programming, can u please tell me how to perform XOr operation of two strings. i tried to do xor using ^symbol but this doesnt work. help me with this Thanks (12 Replies)
Discussion started by: anil_uvce
12 Replies
munch(6x)							XScreenSaver manual							 munch(6x)

NAME
munch - munching squares SYNOPSIS
munch [-display host:display.screen] [-foreground color] [-background color] [-window] [-root] [-mono] [-install] [-visual visual] [-delay usecs] [-xor] [-noxor] [-clear number] [-simul number] [-classic | -mismunch | -random] [-fps] DESCRIPTION
The munch program performs the munching squares hack. It picks square size, position, and gravity randomly. It also displays a creatively broken misimplementation of the classic algorithm. The munching squares hack consists of drawing Y = X XOR T for a range of X and T over and over until all the possible combinations of X and T have come up. It was reportedly discovered by Jackson Wright in 1962 and took 5 instructions of PDP-6 code. OPTIONS
munch accepts the following options: -window Draw on a newly-created window. This is the default. -root Draw on the root window. -mono If on a color display, pretend we're on a monochrome display. -install Install a private colormap for the window. -visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -delay usecs The delay between steps of the animation, in microseconds. Default: 2500. -xor Use the XOR drawing function. This is the default. -no-xor Don't use the XOR drawing function. -clear number Number of squares to misdraw before clearing the display. Default: 65. -simul number Number of squares to misdraw simultaneously. Default: 5. -classic Draw classic munching squares only. -mismunch Draw "mismunch" only. -random Do one or the other. -fps Display the current frame rate and CPU load. ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1), http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html HISTORY
HAKMEM: MIT AI Memo 239, Feb. 29, 1972. Beeler, M., Gosper, R.W., and Schroeppel, R. "Unless otherwise stated, all computer programs are in PDP-6/10 assembly language." ITEM 146: MUNCHING SQUARES Another simple display program. It is thought that this was discovered by Jackson Wright on the RLE PDP-1 circa 1962. DATAI 2 ADDB 1,2 ROTC 2,-22 XOR 1,2 JRST .-4 2=X, 3=Y. Try things like 1001002 in data switches. This also does interesting things with operations other than XOR, and rota- tions other than -22. (Try IOR; AND; TSC; FADR; FDV(!); ROT -14, -9, -20, ...) ITEM 147 (Schroeppel): Munching squares is just views of the graph Y = X XOR T for consecutive values of T = time. ITEM 148 (Cohen, Beeler): A modification to munching squares which reveals them in frozen states through opening and closing curtains: insert FADR 2,1 before the XOR. Try data switches = 4000,,4 1000,,2002 2000,,4 0,,1002 (Notation: <left half>,,<right half>) Also try the FADR after the XOR, switches = 1001,,1. COPYRIGHT
Copyright 1997 Tim Showalter. Copyright 2004 Steven Hazel. Copyright 1992-2008 Jamie Zawinski. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in sup- porting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. X Version 11 5.15 (28-Sep-2011) munch(6x)
All times are GMT -4. The time now is 05:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy