if b[i-1] = 1
g[i] = not b[i]
else
g[i] = b[i]
Or: g = b xor (b logically right shifted 1 time)
b[0] = g[0]
for other bits:
b[i] = g[i] xor b[i-1]
gray
should be a function.
testString: assert(typeof gray=='function','gray
should be a function.');
- text: gray(true,177)
should return a number.
testString: assert(typeof gray(true,177)=='number','gray(true,177)
should return a number.');
- text: gray(true,177)
should return 233
.
testString: assert.equal(gray(true,177),233,'gray(true,177)
should return 233
.');
- text: gray(true,425)
should return 381
.
testString: assert.equal(gray(true,425),381,'gray(true,425)
should return 381
.');
- text: gray(true,870)
should return 725
.
testString: assert.equal(gray(true,870),725,'gray(true,870)
should return 725
.');
- text: gray(false,233)
should return 177
.
testString: assert.equal(gray(false,233),177,'gray(false,233)
should return 177
.');
- text: gray(false,381)
should return 425
.
testString: assert.equal(gray(false,381),425,'gray(false,381)
should return 425
.');
- text: gray(false,725)
should return 870
.
testString: assert.equal(gray(false,725),870,'gray(false,725)
should return 870
.');
```