Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell98 |

Gray code is a binary numeral system where two successive numbers differ in only one bit.

This module provides an interface to encode/decode

types.`Bits`

Algorithm: Haupt, R.L. and Haupt, S.E., Practical Genetic Algorithms, Second ed. (2004), 5.4. Gray Codes.

# Documentation

gray :: (Bits a, Num a) => a -> a Source

Convert an integer number from binary to Gray code.

Results on negative values of unbounded integral types (like `Integer`

) may be wrong.