set/clear: shorter & a few nanoseconds faster
This commit is contained in:
parent
464d9d3f75
commit
f5ab1de0b6
1 changed files with 2 additions and 2 deletions
|
@ -24,11 +24,11 @@ var test = func(n, b) {
|
|||
|
||||
|
||||
# returns number <n> with bit <b> set
|
||||
var set = func(n, b) test(n, b) ? n : n + bit[b];
|
||||
var set = func(n, b) n + test(n, b) * bit[b];
|
||||
|
||||
|
||||
# returns number <n> with bit <b> cleared
|
||||
var clear = func(n, b) test(n, b) ? n - bit[b] : n;
|
||||
var clear = func(n, b) n - test(n, b) * bit[b];
|
||||
|
||||
|
||||
# returns number <n> with bit <b> toggled
|
||||
|
|
Loading…
Add table
Reference in a new issue