Learn R Programming

adana (version 1.1.0)

gray2bin2: Convert gray code to binary integer #2

Description

The function gray2bin2 converts a gray-coded integer to a binary-coded number. The conversion function is performed according to the algorithm given by Chakraborty and Janikov (2003).

Usage

gray2bin2(gray)

Arguments

gray

A gray coded number.

Value

Returns the binary coded integer equivalent of the input number.

Details

To convert gray coded numbers to binary numbers, a conversion function is defined using the algorithm given by Chakraborty and Janikov (2003). This function is a generic function that does not use the xor operator.

References

Chakraborty, U.K., and Janikow C.Z. (2003). An analysis of Gray versus binary encoding in genetic search. Information Sciences, 156 (3-4), 253-269.

See Also

bin2gray, gray2bin

Examples

Run this code
# NOT RUN {
gray = c(1,1,1,0) 
gray2bin2(gray)       # returns 1011

gray = c(1,1,1,1)
gray2bin2(gray)       # returns 1010

# }

Run the code above in your browser using DataLab