-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitwise_operators_table.html
More file actions
306 lines (278 loc) · 10.5 KB
/
Copy pathbitwise_operators_table.html
File metadata and controls
306 lines (278 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bitwise Operátorok</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
color: white;
}
.container {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: 30px;
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
border: 1px solid rgba(255, 255, 255, 0.18);
}
h1 {
text-align: center;
margin-bottom: 30px;
font-size: 2.5em;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.table-container {
overflow-x: auto;
margin-bottom: 30px;
}
table {
width: 100%;
border-collapse: collapse;
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
th {
background: rgba(255, 255, 255, 0.2);
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 0.9em;
}
tr:hover {
background: rgba(255, 255, 255, 0.1);
transform: scale(1.01);
transition: all 0.3s ease;
}
.operator {
font-family: 'Courier New', monospace;
font-size: 1.3em;
font-weight: bold;
color: #4ecdc4;
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.binary {
font-family: 'Courier New', monospace;
color: #ff6b6b;
font-weight: bold;
}
.example-section {
background: rgba(255, 255, 255, 0.05);
padding: 20px;
border-radius: 10px;
margin: 20px 0;
border-left: 5px solid #4ecdc4;
}
.example-section h3 {
color: #4ecdc4;
margin-top: 0;
}
.code-block {
background: rgba(0, 0, 0, 0.3);
padding: 15px;
border-radius: 8px;
font-family: 'Courier New', monospace;
margin: 10px 0;
border-left: 3px solid #ff6b6b;
}
.language-support {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
margin: 20px 0;
}
.lang-card {
background: rgba(255, 255, 255, 0.1);
padding: 15px;
border-radius: 8px;
text-align: center;
border: 2px solid rgba(255, 255, 255, 0.2);
transition: all 0.3s ease;
}
.lang-card:hover {
transform: translateY(-5px);
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.performance-tip {
background: linear-gradient(45deg, rgba(255, 107, 107, 0.2), rgba(78, 205, 196, 0.2));
padding: 20px;
border-radius: 10px;
margin: 20px 0;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.highlight {
background: rgba(255, 255, 0, 0.2);
padding: 2px 6px;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<h1>🔧 Bitwise Operátorok Referencia</h1>
<div class="table-container">
<table>
<thead>
<tr>
<th>Operátor</th>
<th>Név</th>
<th>Leírás</th>
<th>Példa (A=12, B=7)</th>
<th>Eredmény</th>
<th>Bináris Forma</th>
</tr>
</thead>
<tbody>
<tr>
<td class="operator">&</td>
<td><strong>AND (ÉS)</strong></td>
<td>Bit 1 lesz, ha mindkét operandusban 1</td>
<td>A & B</td>
<td>4</td>
<td class="binary">1100 & 0111 = 0100</td>
</tr>
<tr>
<td class="operator">|</td>
<td><strong>OR (VAGY)</strong></td>
<td>Bit 1 lesz, ha legalább egy operandusban 1</td>
<td>A | B</td>
<td>15</td>
<td class="binary">1100 | 0111 = 1111</td>
</tr>
<tr>
<td class="operator">^</td>
<td><strong>XOR (Kizáró VAGY)</strong></td>
<td>Bit 1 lesz, ha pontosan egy operandusban 1</td>
<td>A ^ B</td>
<td>11</td>
<td class="binary">1100 ^ 0111 = 1011</td>
</tr>
<tr>
<td class="operator">~</td>
<td><strong>NOT (NEM/Komplement)</strong></td>
<td>Minden bit invertálása (0→1, 1→0)</td>
<td>~A</td>
<td>-13</td>
<td class="binary">~1100 = ...11110011</td>
</tr>
<tr>
<td class="operator"><<</td>
<td><strong>Bal Shift</strong></td>
<td>Biteket balra tolja, nullákkal tölt fel</td>
<td>A << 2</td>
<td>48</td>
<td class="binary">1100 << 2 = 110000</td>
</tr>
<tr>
<td class="operator">>></td>
<td><strong>Jobb Shift</strong></td>
<td>Biteket jobbra tolja</td>
<td>A >> 2</td>
<td>3</td>
<td class="binary">1100 >> 2 = 11</td>
</tr>
</tbody>
</table>
</div>
<div class="example-section">
<h3>🚀 Gyakorlati Példák C/C++-ban</h3>
<div class="code-block">
// Páros/páratlan ellenőrzés (gyorsabb mint % 2)<br>
bool isEven(int n) { return (n & 1) == 0; }<br><br>
// Gyors szorzás/osztás 2 hatványaival<br>
int multiply_by_8(int x) { return x << 3; } // x * 8<br>
int divide_by_4(int x) { return x >> 2; } // x / 4<br><br>
// Bit beállítása/törlése<br>
int setBit(int n, int pos) { return n | (1 << pos); }<br>
int clearBit(int n, int pos) { return n & ~(1 << pos); }<br>
int toggleBit(int n, int pos) { return n ^ (1 << pos); }
</div>
</div>
<div class="example-section">
<h3>☕ Java/Kotlin Példák</h3>
<div class="code-block">
// Java/Kotlin<br>
fun isPowerOfTwo(n: Int): Boolean = n > 0 && (n and (n - 1)) == 0<br><br>
// Unsigned right shift (Java/Kotlin csak)<br>
val result = number ushr 2 // Kotlin<br>
int result = number >>> 2; // Java<br><br>
// Bit manipuláció<br>
val flags = 0b1010_1100<br>
val hasFlag = (flags and 0b0000_0100) != 0
</div>
</div>
<h3>🌍 Nyelvi Támogatás</h3>
<div class="language-support">
<div class="lang-card">
<strong>C/C++</strong><br>
Teljes támogatás<br>
Natív sebességű
</div>
<div class="lang-card">
<strong>Java</strong><br>
Teljes támogatás<br>
+ unsigned shift
</div>
<div class="lang-card">
<strong>Kotlin</strong><br>
Funkciók formájában<br>
(and, or, xor, shl, shr)
</div>
<div class="lang-card">
<strong>Assembly</strong><br>
Direkt gépi utasítások<br>
Leggyorsabb
</div>
<div class="lang-card">
<strong>Python</strong><br>
Teljes támogatás<br>
Lassabb végrehajtás
</div>
<div class="lang-card">
<strong>JavaScript</strong><br>
32-bit korlátozott<br>
Automatikus konverzió
</div>
</div>
<div class="performance-tip">
<h3>⚡ Teljesítmény Tippek</h3>
<p><span class="highlight">Igen, gyorsabbak!</span> A bitwise operátorok gyakran gyorsabbak, mert:</p>
<ul>
<li><strong>Közvetlen gépi utasítások</strong> - 1 CPU ciklus alatt végrehajthatók</li>
<li><strong>Shift operátorok</strong> gyorsabbak mint szorzás/osztás</li>
<li><strong>Bit tesztek</strong> gyorsabbak mint modulo műveletek</li>
<li><strong>Flag kezelés</strong> memória hatékony</li>
</ul>
<p><strong>Mikor használd:</strong></p>
<ul>
<li>Grafikai programozás (RGB színek manipulációja)</li>
<li>Hálózati protokollok (header mezők)</li>
<li>Embedded rendszerek (memória spórolás)</li>
<li>Kriptográfia és hash algoritmusok</li>
<li>Játékfejlesztés (gyors matematika)</li>
</ul>
</div>
<div class="example-section">
<h3>🎯 Történelmi Kontextus</h3>
<p>Igen, a gépi kód és assembly az elsődleges szint ahol ezek működnek. Bár a FORTRAN (1957) előbb volt,
a C (1972) és C++ (1985) tette ezeket széles körben elérhetővé. A bitwise operátorok közvetlenül
megfelelnek a processzor ALU (Arithmetic Logic Unit) utasításainak.</p>
</div>
</div>
</body>
</html>