XhCode Online Converter Tools

Binary / Decimal / Hexadecimal / Ascii Converter



Binary / Decimal / Hexadecimal / Ascii Online Converter Tools

A Binary, Decimal, Hexadecimal, and ASCII Converter is a tool that allows you to easily convert between different number systems (binary, decimal, and hexadecimal) and also encode/decode text in ASCII. These conversions are often used in computing, programming, and data manipulation.

Number Systems Overview:
Binary (Base 2): A number system using only two digits, 0 and 1. Commonly used in computing and digital electronics.
Decimal (Base 10): The standard number system used by humans, consisting of digits 0-9.
Hexadecimal (Base 16): A number system using 16 digits, 0-9 and A-F, often used in programming to represent binary data more compactly.
ASCII (American Standard Code for Information Interchange): A character encoding standard that represents text in computers using 7 or 8 bits per character. ASCII codes range from 0 to 127 (for standard ASCII) or up to 255 (extended ASCII).
Conversion Between Binary, Decimal, Hexadecimal, and ASCII:
1. Binary to Decimal:
To convert a binary number to decimal, sum the values of the positions where there is a 1. Each position represents a power of 2.

Example: Binary: 1101

1
×
2
3
+
1
×
2
2
+
0
×
2
1
+
1
×
2
0
=
8
+
4
+
0
+
1
=
13
1×2
3
+1×2
2
+0×2
1
+1×2
0
=8+4+0+1=13
So, 1101 (binary) = 13 (decimal).

2. Decimal to Binary:
To convert a decimal number to binary, repeatedly divide the decimal number by 2 and record the remainder.

Example: Decimal: 13

13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
So, 13 (decimal) = 1101 (binary).

3. Binary to Hexadecimal:
Group the binary digits in sets of 4 (starting from the right), then convert each group to its hexadecimal equivalent.

Example: Binary: 11011011

Group the binary: 1101 1011
Convert each group:
1101 = D (in hexadecimal)
1011 = B (in hexadecimal)
So, 11011011 (binary) = DB (hexadecimal).

4. Hexadecimal to Binary:
Convert each hexadecimal digit to its 4-bit binary equivalent.

Example: Hexadecimal: DB

D = 1101 (binary)
B = 1011 (binary)
So, DB (hexadecimal) = 11011011 (binary).

5. Decimal to Hexadecimal:
To convert a decimal number to hexadecimal, repeatedly divide the decimal number by 16 and record the remainder.

Example: Decimal: 13

13 ÷ 16 = 0 remainder 13
So, 13 (decimal) = D (hexadecimal).

6. Hexadecimal to Decimal:
To convert hexadecimal to decimal, multiply each digit by 16 raised to the power of its position and sum the values.

Example: Hexadecimal: DB

D = 13 (in decimal)
B = 11 (in decimal)
So,
13
×
16
1
+
11
×
16
0
=
208
+
11
=
219
13×16
1
+11×16
0
=208+11=219.

So, DB (hexadecimal) = 219 (decimal).

7. ASCII to Decimal/Binary/Hexadecimal:
Each character in ASCII is represented by a unique number.

Example: Character: A

ASCII code for A is 65 in decimal.
65 in binary is 1000001.
65 in hexadecimal is 41.
So, A (ASCII) = 65 (decimal), 1000001 (binary), 41 (hexadecimal).

8. Decimal/Binary/Hexadecimal to ASCII:
To convert from Decimal/Binary/Hexadecimal to ASCII, use the corresponding value as the ASCII code.

Example: Decimal: 65

ASCII character for 65 is A.
Binary: 1000001

ASCII character for 1000001 (binary) is A.
Hexadecimal: 41

ASCII character for 41 (hexadecimal) is A.
Online Converters and Tools:
1. Binary to Decimal:
html

<script>
function binaryToDecimal(binary) {
return parseInt(binary, 2);
}
</script>
2. Decimal to Binary:
html

<script>
function decimalToBinary(decimal) {
return (decimal >>> 0).toString(2);
}
</script>
3. Binary to Hexadecimal:
html

<script>
function binaryToHex(binary) {
return parseInt(binary, 2).toString(16).toUpperCase();
}
</script>
4. Hexadecimal to Binary:
html

<script>
function hexToBinary(hex) {
return parseInt(hex, 16).toString(2);
}
</script>
5. Decimal to Hexadecimal:
html

<script>
function decimalToHex(decimal) {
return decimal.toString(16).toUpperCase();
}
</script>
6. Hexadecimal to Decimal:
html

<script>
function hexToDecimal(hex) {
return parseInt(hex, 16);
}
</script>
7. ASCII to Binary/Decimal/Hex:
html

<script>
function asciiToBinary(str) {
return str.split('').map(function(c) {
return c.charCodeAt(0).toString(2).padStart(8, '0');
}).join(' ');
}

function asciiToDecimal(str) {
return str.split('').map(function(c) {
return c.charCodeAt(0);
}).join(' ');
}

function asciiToHex(str) {
return str.split('').map(function(c) {
return c.charCodeAt(0).toString(16).toUpperCase();
}).join(' ');
}
</script>
8. Binary/Decimal/Hexadecimal to ASCII:
html

<script>
function binaryToAscii(binary) {
return binary.split(' ').map(function(bin) {
return String.fromCharCode(parseInt(bin, 2));
}).join('');
}

function decimalToAscii(decimal) {
return decimal.split(' ').map(function(dec) {
return String.fromCharCode(dec);
}).join('');
}

function hexToAscii(hex) {
return hex.split(' ').map(function(h) {
return String.fromCharCode(parseInt(h, 16));
}).join('');
}
</script>
Summary of Conversion Methods:
Binary ↔ Decimal: Convert using the powers of 2.
Binary ↔ Hexadecimal: Group binary digits in sets of 4, then convert.
Decimal ↔ Hexadecimal: Use division and remainder.
ASCII ↔ Binary/Decimal/Hex: Use the ASCII value for characters and convert.