פעולה על סיביות – הבדלי גרסאות

תוכן שנמחק תוכן שנוסף
מ סקריפט החלפות (מסוי, לעתים, זיכרון, על ידי, {{הערות שוליים}})
מ עיצוב
שורה 43:
 
=== במתמטיקה ===
<div style="direction: rtl;">בהנחה ש x > y, עבור כל מספר שלם אי־שלילי, ניתן להביע פעולות על סיביות באופן הבא:</div>
<div style="text-align: center;">
<div style="direction: ltr;"><math>x\text{ ANDNOT }yx = \sum_{n=0}^{b}2^n\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2 + 1\right)\left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)]</math></div>
 
<div style="direction: ltr;"><math>x\text{NOT AND }xy = \sum_{n=0}^{b}2^n\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2 + 1\right)\left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right])</math></div>
 
<div style="direction: ltr;"><math>x\text{ AND }y = \sum_{n=0}^{b}2^n\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right)\left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)</math></div>
 
<math>x\text{ OR }y = \sum_{n=0}^{b}2^n\left[\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right) + \left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right) + \left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right)\left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)\bmod 2\right]\bmod 2\right]</math>
 
<math>x\text{ XOR }y = \sum_{n=0}^{b}2^n\left[\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right) + \left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)\right]\bmod 2\right]</math>
</div>
 
<div style="direction: rtl;">כאשר <math>b</math> הוא מספר הביטים ב־ <math>x = \lfloor\log_2 x\rfloor+1</math> עבור כל <math>x \neq 0</math>.</div>
 
== הערות שוליים ==