flat assembler
Message board for the users of flat assembler.

 Index > Heap > Gray code
Author
Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
What's it used for? I know (basic) things about it, but would like to know what it really is and it's usefulness. I mean, it's a different numbering system, or not?

btw: I know about conversion to and from gray-codes. xor thingy

28 Aug 2006, 14:15
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
28 Aug 2006, 14:42
Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Sorry,

I really can't remember the links, but here's a quote:
Quote:
A Gray code is any binary coding sequence in which only a single bit position changes as we move from one value to the next. There are many such codes, but the traditional one is computed such that the Kth Gray code is K^(K>>1).

The well-known algorithm for conversion from Gray to binary is a linear sequence of XORs that makes it seem each bit must be dealt with separately. Fortunately, that is equivalent to a parallel prefix XOR that can be computed using SWAR techniques in log time. For 32-bit Gray code values produced as described above, the conversion from Gray code back to unsigned binary is:

unsigned int
g2b(unsigned int gray)
{
gray ^= (gray >> 16);
gray ^= (gray >> ;
gray ^= (gray >> 4);
gray ^= (gray >> 2);
gray ^= (gray >> 1);
return(gray);
}
That's C source, but of course ">>" is right shift, ^= means gray = gray xor ..., and all that

The problem is I don't even know what it really is. If I did know, I wouldn't have posted it
28 Aug 2006, 15:02
HyperVista

Joined: 18 Apr 2005
Posts: 691
Location: Virginia, USA
HyperVista
It gives a nice explaination of gray codes and links to other resources.
28 Aug 2006, 15:06
Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Thanks
28 Aug 2006, 15:42
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum