問題タブ [boolean-algebra]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
boolean - ブール代数を使用して次の式を単純化する方法は?
ブール代数を使用して次の式を単純化する方法は?
a[b'c+ (b+c')'](a'b+c)
bit-manipulation - ビットいじり : 非負の整数を 2 のべき乗の差としてチェック
問題 : 非負の整数が2^j - 2^k where j>=k>=0
2 のべき乗の差などの形式であるかどうかを確認するn (say)
にはfor eg. 00011110
。連続する 1 のシーケンス (右端) をオフにし、 でゼロ チェックを行いn
ます。ここで私がすることは、steps for solution
00011110
00011111(turn on trailing 0's)
00000000(then turn off trailing 1's)
. この式を使用し(x | (x - 1)) & ((x | (x - 1)) + 1)
ます。しかし、リテラルを使用しないより効率的な式 (おそらく操作の数が少ないため) の((x & -x) + x) & x
後にゼロチェックが続きます。そして、私はこれを理解できませんが、同じことを行うと書かれていますが、私の結果から式を導き出すことはできません. 誰かが私にこれを説明できますか?
EDIT : 32 ビット ワード、2 の補数