1
0
Fork 0

set/clear: shorter & a few nanoseconds faster

This commit is contained in:
mfranz 2008-10-22 23:04:07 +00:00
parent 464d9d3f75
commit f5ab1de0b6

View file

@ -24,11 +24,11 @@ var test = func(n, b) {
# returns number <n> with bit <b> set # 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 # 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 # returns number <n> with bit <b> toggled