public class GrayCode extends Object
Modifier and Type | Method and Description |
---|---|
static long |
decode(long g)
Converts a gray coded number to its natural value.
|
static long |
encode(long n)
Converts a number to its gray coded value.
|
public static long encode(long n) throws IllegalArgumentException
n
- The natural value of the number.IllegalArgumentException
- If n is less than 0.public static long decode(long g)
g
- The gray coded value of the number.Copyright © 2020. All rights reserved.