-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary-to-decimal.html
More file actions
625 lines (593 loc) · 32.3 KB
/
binary-to-decimal.html
File metadata and controls
625 lines (593 loc) · 32.3 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Binary to Decimal Converter | Base 2 to Base 10</title>
<meta name="description"
content="Convert Binary to Decimal and Decimal to Binary numbers instantly. A free, fast, and simple online calculator for developers and students.">
<link rel="canonical" href="https://binary-code-translator.com/binary-to-decimal.html">
<!-- Open Graph Meta Tags -->
<meta property="og:title" content="Binary to Decimal Converter | Base 2 to Base 10">
<meta property="og:description" content="Convert Binary to Decimal and Decimal to Binary numbers instantly. A free, fast, and simple online calculator for developers and students.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://binary-code-translator.com/binary-to-decimal.html">
<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Binary to Decimal Converter | Base 2 to Base 10">
<meta name="twitter:description" content="Convert Binary to Decimal and Decimal to Binary numbers instantly. A free, fast, and simple online calculator for developers and students.">
<!-- Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "Binary to Decimal Converter",
"description": "Free online tool to convert binary code to decimal and decimal to binary",
"url": "https://binary-code-translator.com/binary-to-decimal.html",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Any",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
}
}
</script>
<link rel="stylesheet" href="css/style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<style>
/* Mobile Optimization */
@media (max-width: 768px) {
.container { padding: 0 1rem; }
.converter-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.quick-actions { width: 100%; justify-content: flex-end; margin-top: -2rem; }
.input-actions, .output-actions { flex-wrap: wrap; gap: 0.5rem; }
.input-actions .btn, .output-actions .btn { flex: 1 1 40%; justify-content: center; }
.features-grid, .examples-grid { grid-template-columns: 1fr; }
.table-wrapper {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
margin-bottom: 1rem;
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
}
table { width: 100%; min-width: 300px; }
/* Adjust header font sizes */
h1 { font-size: 1.25rem; }
h2 { font-size: 1.125rem; }
.tagline { font-size: 0.75rem; }
}
</style>
</head>
<body data-mode="binary-decimal">
<header>
<div class="container">
<div class="nav-wrapper">
<div class="logo">
<h1><a href="/">Binary Code Translator</a></h1>
<div class="tagline">Professional Binary to Decimal Converter - Free Online Tool</div>
</div>
<button class="mobile-menu-toggle" id="mobileMenuToggle">☰</button>
<nav>
<ul>
<li><a href="/">Binary Translator</a></li>
<li>
<a href="#" class="active" onclick="return false;">
Number Base Converters
<span class="dropdown-arrow"></span>
</a>
<div class="dropdown">
<div class="dropdown-item">
<div class="dropdown-category">Binary Converters</div>
<a href="binary-to-decimal.html" class="active">
Binary ↔ Decimal
<div class="dropdown-description">Convert between base-2 and base-10</div>
</a>
<a href="binary-to-hex.html">
Binary ↔ Hexadecimal
<div class="dropdown-description">Convert between base-2 and base-16</div>
</a>
</div>
<div class="dropdown-item">
<div class="dropdown-category">Multi-Base Converters</div>
<a href="base-converter.html">
Base 2-62 Converter
<div class="dropdown-description">Convert between any bases 2-62</div>
</a>
</div>
</div>
</li>
<li>
<a href="#" onclick="return false;">
Developer Tools
<span class="dropdown-arrow"></span>
</a>
<div class="dropdown">
<div class="dropdown-item">
<div class="dropdown-category">Encoding</div>
<a href="base64-encoder.html">
Base64 Encoder/Decoder
<div class="dropdown-description">Encode and decode Base64 strings</div>
</a>
<a href="url-encoder.html">
URL Encoder/Decoder
<div class="dropdown-description">Encode and decode URLs</div>
</a>
<a href="#" onclick="alert('Coming soon!'); return false;" style="opacity: 0.6;">
HTML Entity Encoder
<div class="dropdown-description">Convert HTML to entities</div>
</a>
</div>
<div class="dropdown-item">
<div class="dropdown-category">Hash Functions</div>
<a href="#" onclick="alert('Coming soon!'); return false;" style="opacity: 0.6;">
MD5 Hash Generator
<div class="dropdown-description">Generate MD5 checksums</div>
</a>
<a href="#" onclick="alert('Coming soon!'); return false;" style="opacity: 0.6;">
SHA256 Generator
<div class="dropdown-description">Generate SHA256 hashes</div>
</a>
</div>
<div class="dropdown-item">
<div class="dropdown-category">Formatters</div>
<a href="#" onclick="alert('Coming soon!'); return false;" style="opacity: 0.6;">
JSON Formatter
<div class="dropdown-description">Format and validate JSON</div>
</a>
<a href="#" onclick="alert('Coming soon!'); return false;" style="opacity: 0.6;">
XML Formatter
<div class="dropdown-description">Format and validate XML</div>
</a>
</div>
</div>
</li>
<li><a href="blog/index.html">Blog</a></li>
</ul>
</nav>
</div>
</div>
</header>
<main class="container">
<section class="converter-section">
<div class="converter-box">
<div class="converter-header">
<h2>Binary to Decimal Converter</h2>
<div class="quick-actions">
<button id="btnSwap" class="btn btn-icon" title="Swap Input/Output" aria-label="Swap Input and Output">⇄</button>
<button id="btnHistory" class="btn btn-icon" title="View History" aria-label="View Conversion History">📜</button>
</div>
</div>
<div class="conversion-indicator" id="converterIndicator" style="display: none;"></div>
<div class="input-group">
<div class="label-container">
<label id="labelLeft" for="inputLeft">
<span class="label-icon">💻</span>
<span class="label-text">Binary Input (Base 2)</span>
</label>
<div class="stats-container">
<span class="char-count" id="charCountLeft">0 bits</span>
<span class="word-count" id="wordCountLeft">0 groups</span>
<span class="line-count" id="lineCountLeft">0 lines</span>
</div>
</div>
<div class="input-wrapper">
<textarea id="inputLeft" placeholder="Enter binary number here... Try: 101010 or 1100 1011" autofocus></textarea>
<div id="dragOverlay" class="drag-overlay">
📁 Drop file here to convert
</div>
</div>
<div class="input-actions">
<button class="btn btn-copy" data-target="inputLeft">
<span class="btn-icon">📋</span>
Copy Binary
</button>
<button class="btn btn-paste" data-target="inputLeft">
<span class="btn-icon">📥</span>
Paste
</button>
<label class="btn btn-upload">
<span class="btn-icon">📁</span>
Upload File
<input type="file" id="fileUpload" style="display:none;" accept=".txt,.json,.xml,.csv">
</label>
<button class="btn btn-clear" data-target="inputLeft">
<span class="btn-icon">🗑️</span>
Clear
</button>
</div>
</div>
<div class="input-group">
<div class="label-container">
<label id="labelRight" for="inputRight">
<span class="label-icon">🔢</span>
<span class="label-text">Decimal Output (Base 10)</span>
</label>
<div class="stats-container">
<span class="char-count" id="charCountRight">0 digits</span>
<span class="word-count" id="wordCountRight">0 numbers</span>
<span class="line-count" id="lineCountRight">0 lines</span>
</div>
</div>
<div class="input-wrapper">
<textarea id="inputRight" placeholder="Converted decimal result will appear here..." readonly></textarea>
</div>
<div class="output-actions">
<button class="btn btn-copy" data-target="inputRight">
<span class="btn-icon">📋</span>
Copy Decimal
</button>
<button id="btnDownload" class="btn">
<span class="btn-icon">💾</span>
Download
</button>
<button id="btnShare" class="btn">
<span class="btn-icon">🔗</span>
Share
</button>
</div>
</div>
<div id="errorMsg" class="error-msg"></div>
</div>
</section>
<!-- Features Section -->
<section class="features-section collapsible-section">
<div class="section-header" data-target="features">
<h2 class="section-title">Key Features</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="features">
<div class="features-grid">
<div class="feature-card">
<div class="feature-icon">⚡</div>
<h3>Real-time Binary to Decimal Conversion</h3>
<p>Instantly convert binary numbers to decimal and vice versa with automatic format detection. The most efficient binary to decimal converter online.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔄</div>
<h3>Bidirectional Base Conversion</h3>
<p>Seamlessly switch between binary (base-2) and decimal (base-10) with intelligent number format adaptation and validation.</p>
</div>
<div class="feature-card">
<div class="feature-icon">📊</div>
<h3>Advanced Number Analytics</h3>
<p>Real-time tracking of bits, groups, and numbers with visual conversion indicators and error detection for invalid binary input.</p>
</div>
<div class="feature-card">
<div class="feature-icon">📁</div>
<h3>Batch File Processing</h3>
<p>Upload and convert multiple binary numbers from files with support for TXT, JSON, XML, and CSV formats.</p>
</div>
<div class="feature-card">
<div class="feature-icon">💾</div>
<h3>Conversion History</h3>
<p>Save and access your binary to decimal conversions with favorites, export options, and efficient history management.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔒</div>
<h3>Secure Local Processing</h3>
<p>All binary to decimal conversions happen locally in your browser, ensuring your data never leaves your device.</p>
</div>
</div>
</div>
</section>
<!-- How to Use Section -->
<section class="how-to-section collapsible-section">
<div class="section-header" data-target="howto">
<h2 class="section-title">How to Use Binary to Decimal Converter</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="howto">
<div class="steps-container">
<div class="step-item">
<div class="step-number">1</div>
<div class="step-content">
<h3>💻 Enter Binary Input</h3>
<p>Type or paste your binary number into the input field. The tool supports:</p>
<ul>
<li>Binary numbers (0s and 1s)</li>
<li>Grouped binary with spaces (e.g., "1010 1100")</li>
<li>File upload (TXT, JSON, XML, CSV formats)</li>
</ul>
</div>
</div>
<div class="step-item">
<div class="step-number">2</div>
<div class="step-content">
<h3>⚡ Instant Decimal Conversion</h3>
<p>Watch as your binary converts automatically to decimal:</p>
<ul>
<li>Binary → Decimal: Real-time base conversion</li>
<li>Live bit count and number tracking</li>
<li>Error detection for invalid binary input</li>
</ul>
</div>
</div>
<div class="step-item">
<div class="step-number">3</div>
<div class="step-content">
<h3>🔧 Use Smart Tools</h3>
<p>Take advantage of built-in features for better productivity:</p>
<ul>
<li><strong>Swap ↔️</strong> Instantly switch input/output</li>
<li><strong>Copy 📋</strong> One-click copy to clipboard</li>
<li><strong>Paste 📥</strong> Quick paste from clipboard</li>
<li><strong>History 📜</strong> Access previous conversions</li>
</ul>
</div>
</div>
<div class="step-item">
<div class="step-number">4</div>
<div class="step-content">
<h3>💾 Save or Share</h3>
<p>Export your converted decimal results in multiple ways:</p>
<ul>
<li><strong>Download File:</strong> Save as text file</li>
<li><strong>Share Link:</strong> Copy URL for sharing</li>
<li><strong>Convert History:</strong> Access your previous work</li>
<li><strong>Examples:</strong> Try pre-built conversion examples</li>
</ul>
</div>
</div>
</div>
<!-- Quick Start Tips -->
<div class="quick-tips">
<h4>⚡ Quick Start Examples</h4>
<div class="tips-grid">
<div class="tip-item">
<strong>Basic:</strong> "1010" → 10
</div>
<div class="tip-item">
<strong>Grouped:</strong> "1010 1100" → 172
</div>
<div class="tip-item">
<strong>Large:</strong> "11111111" → 255
</div>
<div class="tip-item">
<strong>Complex:</strong> "1100 1011 0110" → 3270
</div>
</div>
</div>
</div>
</section>
<!-- Examples Section -->
<section class="examples-section collapsible-section">
<div class="section-header" data-target="examples">
<h2 class="section-title">Binary to Decimal Examples</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="examples">
<div class="examples-grid">
<!-- Basic Examples -->
<div class="example-item">
<div class="example-preview">
<span class="example-type">Basic:</span> 1010
<small>Simple binary</small>
</div>
<div class="example-code">
<span class="example-type">Decimal:</span>
<code>10</code>
</div>
<button class="btn btn-example" data-text="1010">Convert</button>
</div>
<!-- Byte Example -->
<div class="example-item">
<div class="example-preview">
<span class="example-type">Byte:</span> 11111111
<small>Maximum 8-bit</small>
</div>
<div class="example-code">
<span class="example-type">Decimal:</span>
<code>255</code>
</div>
<button class="btn btn-example" data-text="11111111">Convert</button>
</div>
<!-- Grouped Binary -->
<div class="example-item">
<div class="example-preview">
<span class="example-type">Grouped:</span> 1010 1100
<small>With spaces</small>
</div>
<div class="example-code">
<span class="example-type">Decimal:</span>
<code>172</code>
</div>
<button class="btn btn-example" data-text="1010 1100">Convert</button>
</div>
<!-- 16-bit Example -->
<div class="example-item">
<div class="example-preview">
<span class="example-type">16-bit:</span> 1111 1111 1111 1111
<small>Maximum 16-bit</small>
</div>
<div class="example-code">
<span class="example-type">Decimal:</span>
<code>65535</code>
</div>
<button class="btn btn-example" data-text="1111 1111 1111 1111">Convert</button>
</div>
<!-- Power of 2 -->
<div class="example-item">
<div class="example-preview">
<span class="example-type">Power of 2:</span> 10000000
<small>2^7</small>
</div>
<div class="example-code">
<span class="example-type">Decimal:</span>
<code>128</code>
</div>
<button class="btn btn-example" data-text="10000000">Convert</button>
</div>
<!-- Zero Example -->
<div class="example-item">
<div class="example-preview">
<span class="example-type">Zero:</span> 00000000
<small>All zeros</small>
</div>
<div class="example-code">
<span class="example-type">Decimal:</span>
<code>0</code>
</div>
<button class="btn btn-example" data-text="00000000">Convert</button>
</div>
</div>
</div>
</section>
<!-- Educational Section -->
<section class="educational-section collapsible-section">
<div class="section-header" data-target="educational">
<h2 class="section-title">Understanding Binary to Decimal Conversion</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="educational">
<div class="educational-content">
<div class="edu-text">
<h3>Binary Number System</h3>
<p>Binary is a base-2 number system that uses only two digits: 0 and 1. Each position in a binary number represents a power of 2, starting from the rightmost digit (2^0).</p>
<h3>How Binary to Decimal Conversion Works</h3>
<p>To convert binary to decimal, multiply each binary digit by its corresponding power of 2 and sum all the results. For example, binary 1010 converts to decimal 10:</p>
<ul>
<li>1 × 2³ = 1 × 8 = 8</li>
<li>0 × 2² = 0 × 4 = 0</li>
<li>1 × 2¹ = 1 × 2 = 2</li>
<li>0 × 2⁰ = 0 × 1 = 0</li>
<li>Total: 8 + 0 + 2 + 0 = 10</li>
</ul>
<h3>Common Binary Patterns</h3>
<p>Understanding common binary patterns helps in programming and digital logic design:</p>
<ul>
<li><strong>00000001</strong> = 1 (2⁰)</li>
<li><strong>00000010</strong> = 2 (2¹)</li>
<li><strong>00000100</strong> = 4 (2²)</li>
<li><strong>00001000</strong> = 8 (2³)</li>
<li><strong>11111111</strong> = 255 (Maximum 8-bit value)</li>
</ul>
</div>
<div class="edu-visual">
<div class="binary-table">
<h4>Binary to Decimal Reference</h4>
<div class="table-wrapper">
<table>
<tr><th>Binary</th><th>Calculation</th><th>Decimal</th></tr>
<tr><td>0001</td><td>1×2³</td><td>1</td></tr>
<tr><td>0010</td><td>1×2²</td><td>2</td></tr>
<tr><td>0100</td><td>1×2¹</td><td>4</td></tr>
<tr><td>1000</td><td>1×2⁰</td><td>8</td></tr>
<tr><td>1010</td><td>1×2³ + 1×2¹</td><td>10</td></tr>
<tr><td>1111</td><td>1×2³ + 1×2² + 1×2¹ + 1×2⁰</td><td>15</td></tr>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- FAQ Section -->
<section class="faq-section collapsible-section">
<div class="section-header" data-target="faq">
<h2 class="section-title">Frequently Asked Questions</h2>
<span class="section-toggle">▼</span>
</div>
<div class="section-content" id="faq">
<div class="faq-container">
<div class="faq-item">
<div class="faq-question">
<h3>How do I convert binary to decimal?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Simply enter your binary number (sequence of 0s and 1s) in the input field, and our tool will automatically convert it to decimal. You can also enter decimal numbers to convert them to binary.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>What is the largest binary number I can convert?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Our tool can handle binary numbers of arbitrary length, limited only by your browser's capabilities. Common ranges include 8-bit (0-255), 16-bit (0-65535), and 32-bit numbers.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>Can I convert multiple binary numbers at once?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Yes! You can enter multiple binary numbers separated by spaces or newlines, and our tool will convert all of them. You can also upload a file containing multiple binary numbers.</p>
</div>
</div>
<div class="faq-item">
<div class="faq-question">
<h3>Is this binary to decimal converter free?</h3>
<span class="faq-toggle">+</span>
</div>
<div class="faq-answer">
<p>Yes! Our binary to decimal converter is completely free to use. No registration required, no hidden fees, and unlimited conversions.</p>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer>
<div class="container">
<div class="footer-content">
<div class="footer-section collapsed">
<h3>Binary Code Translator <span class="footer-toggle">▼</span></h3>
<div class="footer-toggle-content">
<p>Free online tool for converting between binary and decimal. Fast, secure, and privacy-focused.</p>
</div>
</div>
<div class="footer-section collapsed">
<h4>Tools <span class="footer-toggle">▼</span></h4>
<div class="footer-toggle-content">
<ul>
<li><a href="/">Binary Translator</a></li>
<li><a href="binary-to-decimal.html" class="active">Binary to Decimal</a></li>
<li><a href="binary-to-hex.html">Binary to Hex</a></li>
</ul>
</div>
</div>
<div class="footer-section collapsed">
<h4>Legal <span class="footer-toggle">▼</span></h4>
<div class="footer-toggle-content">
<ul>
<li><a href="legal/privacy.html">Privacy Policy</a></li>
<li><a href="legal/terms.html">Terms of Service</a></li>
<li><a href="legal/cookies.html">Cookie Policy</a></li>
</ul>
</div>
</div>
</div>
<div class="footer-bottom">
<p>© 2025 Binary Code Translator. All rights reserved.</p>
<p>The most trusted binary to decimal converter online - Free, secure, and privacy-focused conversion tool.</p>
</div>
</div>
</footer>
<!-- History Modal -->
<div id="historyModal" class="modal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h2>Conversion History</h2>
<div class="modal-header-actions">
<button id="clearHistory" class="btn btn-danger btn-sm">Clear History</button>
<button class="modal-close" id="closeHistory">×</button>
</div>
</div>
<div class="modal-body">
<div id="historyList" class="history-list">
<p class="no-history">No conversion history yet</p>
</div>
</div>
</div>
</div>
<script src="js/converter.js"></script>
<script src="js/ui-controller.js"></script>
<script src="js/enhanced-ui.js"></script>
</body>
</html>