ﯽﺘﯿﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ


فهرست مطالب

    نمایش فهرست مطالب


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺘﯿﺑ ﯼﺎﻫﺮﮕﻠﻤﻋ

&

ﺪﻨﮐ ﯽﻣ ﻢﯿﻈﻨﺗ 1 ﯼﻭﺭ ﺍﺭ ﺖﯿﺑ ﺮﻫ ،ﺪﻨﺷﺎﺑ 1 ﺖﯿﺑ ﻭﺩ ﺮﻫ ﺮﮔﺍ .ﻭ ﻖﻄﻨﻣ

|

ﺪﻨﮐ ﯽﻣ ﻢﯿﻈﻨﺗ 1 ﯼﻭﺭ ﺍﺭ ﺖﯿﺑ ﺮﻫ ،ﺪﺷﺎﺑ 1 ﺖﯿﺑ ﻭﺩ ﺯﺍ ﯽﮑﯾ ﺮﮔﺍ .ﺎﯾ ﻖﻄﻨﻣ

^

ﺪﻨﮐ ﯽﻣ ﻢﯿﻈﻨﺗ 1 ﯼﻭﺭ ﺍﺭ ﺖﯿﺑ ﺮﻫ ،ﺪﺷﺎﺑ 1 ﺖﯿﺑ ﻭﺩ ﺯﺍ ﯽﮑﯾ ﻂﻘﻓ ﺮﮔﺍ .XOR ﻖﻄﻨﻣ

~

ﺪﻨﮐ ﯽﻣ ﺱﻮﮑﻌﻣ ﺍﺭ ﺎﻫ ﺖﯿﺑ ﻪﻤﻫ .ﻪﻧ ﻖﻄﻨﻣ

<<

ﺪﻨﺘﻔﯿﺑ ﻦﯿﯾﺎﭘ ﭗﭼ ﯼﺎﻫﺖﻤﺴﻗ ﻪﮐ ﺪﻫﺩﯽﻣ ﻩﺯﺎﺟﺍ ﻭ ﺩﻮﺷﯽﻣ ﺎﺟﻪﺑﺎﺟ ﭗﭼ ﺖﻤﺳ ﻪﺑ ﺖ

>>

ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﺎﻫ ﺖﯿﺑ ﻦﯾﺮﺗ ﺖﺳﺍﺭ ﺖﻤﺳ ﻪﺑ ﻭ ﺩﻮﺷ ﯽﻣ ﺎﺟ ﻪﺑﺎﺟ ﺖﺳﺍﺭ ﺖﻤﺳ ﻪﺑ ﭗﭼ ﺖﻤﺳ ﺯﺍ ﺖﯿﺑ ﻦﯾﺮﺗ

>>>

ﺪﻨﺘﻔﯿﺑ ﺎﻫﺖﯿﺑ ﻦﯾﺮﺗﺖﺳﺍﺭ ﺖﻤﺳ ﺪﻫﺩﯽﻣ ﻩﺯﺎﺟﺍ ﻭ ﺩﻮﺷﯽﻣ ﺎﺟﻪﺑﺎﺟ ﺖﺳﺍﺭ ﺖﻤ

ﺎﻫ ﻝﺎﺜﻣ

Operation Result Same as Result
5 & 1 1 0101 & 0001  0001
5 | 1 5 0101 | 0001  0101
~ 5 10  ~0101  1010
5 << 1 10 0101 << 1  1010
5 ^ 1 4 0101 ^ 0001  0100
5 >> 1 2 0101 >> 1  0010
5 >>> 1 2 0101 >>> 1  0010

ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯽﺘﯿﺑ 32 ﯽﺘﯿﺑ ﯼﺎﻫﺪﻧﻮﻠﻤﻋ ﺯﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﺪﻨﮐ ﯽﻣ ﻩﺮﯿﺧﺫ ﯽﺘﯿﺑ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺎﻬﻧﺁ ﻪﻤﻫ ﺎﻣﺍ ،ﺪﻨﮐ ﯽﻣ ﻩﺮﯿﺧﺫ ﯽﺘﯿﺑ 64 ﺭﻭﺎﻨﺷ ﺰﯿﻤﻣ ﺩﺍﺪﻋﺍ ﺕﺭﻮﺻ

ﺪﻨﮐ ﯽﻣ ﻞﯾﺪﺒﺗ ﺖﯿﺑ 32 ﻪﺑ ﺍﺭ ﺩﺍﺪﻋﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﯽﺘﯿﺑ ﺕﺎﯿﻠﻤﻋ ﻡﺎﺠﻧﺍ ﺯﺍ ﻞﺒﻗ

ﺩﻮﺷ ﯽﻣ ﻞﯾﺪﺒﺗ ﯽﺘﯿﺑ 64 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺑ ﻪﺠﯿﺘﻧ ،ﯽﺘﯿﺑ ﺕﺎﯿﻠﻤﻋ ﻡﺎﺠﻧﺍ ﺯﺍ ﺲﭘ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 10 ﺩﺪﻋ 5 ~ ﻞﯿﻟﺩ ﻦﯿﻤﻫ ﻪﺑ .ﺪﻨﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯽﺘﯿﺑ 4 ﺖﻣﻼﻋ ﻥﻭﺪﺑ ﯼﺮﻨﯾﺎﺑ ﺩﺍﺪﻋ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ -6 .ﺪﻧﺍﺩﺮﮔ ﯽﻤﻧ ﺮﺑ ﺍﺭ 10 ،ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯽﺘﯿﺑ 32 ﻩﺪﺷ ﺎﻀﻣﺍ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ ﺯ

0000000000000000000000000000101 (5)

11111111111111111111111111111010 (~5=-6)

.ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯽﻔﻨﻣ ﺖﻣﻼﻋ ﻥﺍﻮﻨﻋ ﻪﺑ ﭗﭼ ﺖﻤﺳ ﺖﯿﺑ ﺯﺍ ﻩﺪﺷ ﺎﻀﻣﺍ ﺢﯿﺤﺻ ﺩﺪﻋ ﮏﯾ



ﻭ ﯽﺘﯿﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 1 ،ﺪﻨﺷﺎﺑ 1 ﺖﯿﺑ ﻭﺩ ﺮﻫ ﺮﮔﺍ ،ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺖﯿﺑ ﺖﻔﺟ ﮏﯾ ﯼﻭﺭ AND ﺖﯿﺑ ﮏﯾ ﻪﮐ ﯽ

0 & 0

0

0 & 1

0

1 & 0

0

1 & 1

1

1111 & 0000

0000

1111 & 0001

0001

1111 & 0010

0010

1111 & 0100

0100


JavaScript Bitwise OR

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 1 ،ﺪﺷﺎﺑ 1 ﺎﻫ ﺖﯿﺑ ﺯﺍ ﯽﮑﯾ ﺮﮔﺍ ،ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺖﯿﺑ ﺖﻔﺟ ﮏﯾ ﯼﻭﺭ ﯽﺘﯿﺑ OR ﮏﯾ ﻪ

0 | 0

0

0 | 1

1 | 0

1

1 | 1

1

1111 | 0000

1111

1111 | 0001

1111

1111 | 0010

1111

1111 | 0100

1111


JavaScript Bitwise XOR

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 1 ،ﺪﻨﺷﺎﺑ ﺕﻭﺎﻔﺘﻣ ﺎﻫ ﺖﯿﺑ ﺮﮔﺍ ،ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺖﯿﺑ ﺖﻔﺟ ﮏﯾ ﯼﻭﺭ ﯽﺘﯿﺑ XOR ﮏﯾ ﻪ

0 ^ 0

0

0 ^ 1

1 ^ 0

1

1 ^ 1

1111 ^ 0000

1111

1111 ^ 0001

1110

1111 ^ 0010

1101

1111 ^ 0100

1011


(&) ﻭ ﯽﺘﯿﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

Bitwise AND ﺪﻨﺷﺎﺑ 1 ﺖﯿﺑ ﻭﺩ ﺮﻫ ﻪﮐ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 1 ﯽﺗﺭﻮﺻ ﺭﺩ ﺎﻬﻨﺗ:

5

00000000000000000000000000000101

1

00000000000000000000000000000001

5 & 1

00000000000000000000000000000001 (1)

ﻝﺎﺜﻣ

let x = 5 & 1;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Bitwise AND</h1>
<h2>The &amp; Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 5 & 1;
</script>

</body>
</html> 

JavaScript Bitwise OR (|)

Bitwise OR 1 ﺪﺷﺎﺑ 1 ﺎﻫ ﺖﯿﺑ ﺯﺍ ﯽﮑﯾ ﺮﮔﺍ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ:

5

00000000000000000000000000000101

1

00000000000000000000000000000001

5 | 1

0000000000000000000000000000101 (5)

ﻝﺎﺜﻣ

let x = 5 | 1;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Bitwise OR</h1>
<h2>The | Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 5 | 1;
</script>

</body>
</html>

JavaScript Bitwise XOR (^)

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 1 ﯽﺘﯿﺑ XOR ،ﺪﻨﺷﺎﺑ ﺕﻭﺎﻔﺘﻣ ﺎﻫ ﺖﯿﺑ ﺮﮔﺍ

5

00000000000000000000000000000101

1

00000000000000000000000000000001

5 ^ 1

0000000000000000000000000000100 (4)

ﻝﺎﺜﻣ

let x = 5 ^ 1;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Bitwise XOR</h1>
<h2>The ^ Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 5 ^ 1;
</script>

</body>
</html>

(~) NOT ﯽﺘﯿﺑ ﺕﺭﻮﺻ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

5

00000000000000000000000000000101

~5

11111111111111111111111111111010 (-6)

ﻝﺎﺜﻣ

let x = ~5;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Bitwise NOT</h1>
<h2>The ~ Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = ~ 5;
</script>

</body>
</html>

(>>) ﯽﺘﯿﺑ ﭗﭼ ﻪﺑ ﺖﻔﯿﺷ (ﺮﭘ ﺮﻔﺻ) ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

،ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺭﺎﺸﻓ ﻞﺧﺍﺩ ﻪﺑ ﺖﺳﺍﺭ ﺖﻤﺳ ﺯﺍ ﺮﻔﺻ ﺖﯿﺑ ﺪﻨﭼ ﺎﯾ ﮏﯾ .ﺖﺳﺍ ﺮﻔﺻ ﺮﭘ ﭗﭼ ﺖﻔﯿﺷ ﮏﯾ ﻦﯾﺍ

5

00000000000000000000000000000101

5 << 1

0000000000000000000000000001010 (10)

ﻝﺎﺜﻣ

let x = 5 << 1;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Bitwise Left</h1>
<h2>The &lt;&lt; Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 5 << 1;
</script>

</body>
</html>

(<<) ﺖﺳﺍﺭ ﻪﺑ ﯽﺘﯿﺑ ﺮﯿﯿﻐﺗ (ﺖﻣﻼﻋ ﻆﻔﺣ) ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﺪﻧﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺭﺎﺸﻓ ﺖﯿﺑ ﻦﯾﺮﺗ ﭗﭼ ﺖﻤﺳ ﯼﺎﻫ ﯽﭙﮐ .ﺪﻨﮐ ﯽﻣ ﻆﻔﺣ ﺍﺭ ﺖﺳﺍﺭ ﺖﻤﺳ ﺮﯿﯿﻐﺗ ﻪﮐ ﺖﺳﺍ ﯼﺍ ﻪﻧﺎ

-5

11111111111111111111111111111011

-5 >> 1

11111111111111111111111111111101 (-3)

ﻝﺎﺜﻣ

let x = -5 >> 1;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Signed Bitwise Right</h1>
<h2>The &gt;&gt; Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = -5 >> 1;
</script>

</body>
</html>

(<<<) ﺖﺳﺍﺭ Shift (Zero Fill) ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

،ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﻞﻫ ﻞﺧﺍﺩ ﻪﺑ ﭗﭼ ﺖﻤﺳ ﺯﺍ ﺮﻔﺻ ﺖﯿﺑ ﺪﻨﭼ ﺎﯾ ﮏﯾ .ﺖﺳﺍ ﺮﻔﺻ ﻥﺩﺮﮐ ﺮﭘ ﺖﺳﺍﺭ ﺖﻤﺳ ﻪﺑ ﺖﻔﯿﺷ

5

00000000000000000000000000000101

5 >>> 1

00000000000000000000000000000010 (2)

ﻝﺎﺜﻣ

let x = 5 >>> 1;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Unsigned Bitwise Right</h1>
<h2>The &gt;&gt;&gt; Operator</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 5 >>> 1;
</script>

</body>
</html>

ﯼﺮﻨﯾﺎﺑ ﺩﺍﺪﻋﺍ

:ﺪﻨﺘﺴﻫ ﮎﺭﺩ ﻞﺑﺎﻗ ﯽﺘﺣﺍﺭ ﻪﺑ ﺖﯿﺑ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺎﻬﻨﺗ ﺎﺑ ﯼﺮﻨﯾﺎﺑ ﺩﺍﺪﻋﺍ

00000000000000000000000000000001

1

00000000000000000000000000000010

2

00000000000000000000000000000100

4

00000000000000000000000000001000

8

00000000000000000000000000010000

16

00000000000000000000000000100000

32

00000000000000000000000001000000

64

:ﺪﻫﺩ ﯽﻣ ﻥﺎﺸﻧ ﺍﺭ ﯼﺮﻨﯾﺎﺑ ﯼﻮﮕﻟﺍ ﺮﮕﯾﺩ ﺖﯿﺑ ﺪﻨﭼ ﻢﯿﻈﻨﺗ

00000000000000000000000000000101

5 (4 + 1)

00000000000000000000000000001101

13 (8 + 4 + 1)

00000000000000000000000000101101

45 (32 + 8 + 4 + 1)

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺮﯿﺧﺫ ﻭﺩ ﻞﻤﮑﻣ ﺐﻟﺎﻗ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺮﻨﯾﺎﺑ ﺩﺍﺪﻋﺍ

:ﺖﺳﺍ 1 ﻪﻓﺎﺿﺍ ﻪﺑ ﺩﺪﻋ NOT ﯽﺘﯿﺑ ﺕﺭﻮﺻ ﻪﺑ ﯽﻔﻨﻣ ﺩﺪﻋ ﮏﯾ ﻪﮐ ﺖﺳﺍ ﯽﻨﻌﻣ ﻥﺍﺪﺑ ﻦﯾﺍ

00000000000000000000000000000101

5

11111111111111111111111111111011

-5

00000000000000000000000000000110

6

11111111111111111111111111111010

-6

00000000000000000000000000101000

40

11111111111111111111111111011000

-40

:ﯽﺧﻮﺷ

.ﺪﻨﻧﺍﺩ ﯽﻤﻧ ﻪﮐ ﯽﯾﺎﻬﻧﺁ ﻭ ﺪﻨﻤﻬﻓ ﯽﻣ ﺍﺭ ﯼﺮﻨﯾﺎﺑ ﻪﮐ ﯽﯾﺎﻬﻧﺁ :ﺩﺭﺍﺩ ﺩﻮﺟﻭ ﺎﯿﻧﺩ ﺭﺩ ﻡﺩﺁ ﻉﻮﻧ 10 ﻂﻘﻓ


ﯼﺮﻨﯾﺎﺑ ﻪﺑ ﺭﺎﺸﻋﺍ ﻞﯾﺪﺒﺗ

ﻝﺎﺜﻣ

function dec2bin(dec){
  return (dec >>> 0).toString(2);
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Convert Decimal to Binary</h1>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = dec2bin(-5);
function dec2bin(dec){
  return (dec >>> 0).toString(2);
}
</script>

</body>
</html>

ﯼﺭﺎﺸﻋﺍ ﻪﺑ ﯼﺮﻨﯾﺎﺑ ﻞﯾﺪﺒﺗ

ﻝﺎﺜﻣ

function bin2dec(bin){
    return parseInt(bin, 2).toString(10);
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Convert Binary to Decimal</h2>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = bin2dec(101);
function bin2dec(bin){
  return parseInt(bin, 2).toString(10);
}
</script>

</body>
</html>