Converting ASCII to decimal is a common task in computer programming. ASCII is a character encoding standard that assigns a unique number to each character. Decimal, on the other hand, is a base-10
number system that uses ten digits, 0 through 9. Converting ASCII to decimal involves converting each character to its corresponding decimal value.
Conversion
Here's a step-by-step guide on how to convert ASCII to decimal:
- Choose the ASCII character you want to convert to decimal.
- Look up the decimal value of the ASCII character using an ASCII table.
Example
Let's walk through an example to illustrate the process. Suppose we want to convert the ASCII character 'A' to decimal.
- The ASCII value of 'A' is 65.
- The decimal value of 'A' is also 65.
ASCII Table
Character | Description | Decimal |
---|---|---|
0 | Zero | 48 |
1 | One | 49 |
2 | Two | 50 |
3 | Three | 51 |
4 | Four | 52 |
5 | Five | 53 |
6 | Six | 54 |
7 | Seven | 55 |
8 | Eight | 56 |
9 | Nine | 57 |
A | Capital A | 65 |
B | Capital B | 66 |
C | Capital C | 67 |
D | Capital D | 68 |
E | Capital E | 69 |
F | Capital F | 70 |
G | Capital G | 71 |
H | Capital H | 72 |
I | Capital I | 73 |
J | Capital J | 74 |
K | Capital K | 75 |
L | Capital L | 76 |
M | Capital M | 77 |
N | Capital N | 78 |
O | Capital O | 79 |
P | Capital P | 80 |
Q | Capital Q | 81 |
R | Capital R | 82 |
S | Capital S | 83 |
T | Capital T | 84 |
U | Capital U | 85 |
V | Capital V | 86 |
W | Capital W | 87 |
X | Capital X | 88 |
Y | Capital Y | 89 |
Z | Capital Z | 90 |
a | Small a | 97 |
b | Small b | 98 |
c | Small c | 99 |
d | Small d | 100 |
e | Small e | 101 |
f | Small f | 102 |
g | Small g | 103 |
h | Small h | 104 |
i | Small i | 105 |
j | Small j | 106 |
k | Small k | 107 |
l | Small l | 108 |
m | Small m | 109 |
n | Small n | 110 |
o | Small o | 111 |
p | Small p | 112 |
q | Small q | 113 |
r | Small r | 114 |
s | Small s | 115 |
t | Small t | 116 |
u | Small u | 117 |
v | Small v | 118 |
w | Small w | 119 |
x | Small x | 120 |
y | Small y | 121 |
z | Small z | 122 |
See full ascii table here.
Sample Code
This code requires @ilihub/code
npm package to run.
import { AsciiToDecimal } from "@ilihub/code";
const ascii = "Hello World";
const decimal = AsciiToDecimal(ascii);
console.log(decimal);
// Output
// [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
Top comments (0)