binary2gray: Gray encoding for binary strings

Description Usage Arguments Details Author(s) See Also Examples

Description

Functions for computing Gray encoding from/to binary strings.

Usage

1
2

Arguments

x

the string to be evaluated

Details

Gray encoding allows to obtain binary strings not affected by the well-known Hamming cliff problem. With Gray encoding the number of bit differences between any two consecutive values is one, whereas in binary strings this is not always true.

Author(s)

Luca Scrucca

See Also

binary2decimal

Examples

1
2
3
4
5
6
7
8
# Consider a five-bit encoding of values 15 and 16  using the standard 
# binary coding
decimal2binary(15, 5)
decimal2binary(16, 5)
# Moving from 15 to 16 (or viceversa) all five bits need to be changed,
# but using Gray encoding the two binary strings differ by one bit.
binary2gray(decimal2binary(15, 5))
binary2gray(decimal2binary(16, 5))


Search within the GA package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.