if b[i-1] = 1
g[i] = not b[i]
else
g[i] = b[i]
要么: 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
应该是一个功能。
testString: 'assert(typeof gray=="function","gray
should be a function.");'
- text: 'gray(true,177)
应该返回一个数字。'
testString: 'assert(typeof gray(true,177)=="number","gray(true,177)
should return a number.");'
- text: 'gray(true,177)
应该返回233
。'
testString: 'assert.equal(gray(true,177),233,"gray(true,177)
should return 233
.");'
- text: 'gray(true,425)
应该返回381
。'
testString: 'assert.equal(gray(true,425),381,"gray(true,425)
should return 381
.");'
- text: 'gray(true,870)
应该返回725
。'
testString: 'assert.equal(gray(true,870),725,"gray(true,870)
should return 725
.");'
- text: 'gray(false,233)
应该返回177
。'
testString: 'assert.equal(gray(false,233),177,"gray(false,233)
should return 177
.");'
- text: 'gray(false,381)
应该返回425
。'
testString: 'assert.equal(gray(false,381),425,"gray(false,381)
should return 425
.");'
- text: 'gray(false,725)
应该返回870
。'
testString: 'assert.equal(gray(false,725),870,"gray(false,725)
should return 870
.");'
```