DEV Community

harshraj8843 for ilihub

Posted on • Originally published at ilihub.tech

How to Convert Decimal to ASCII

Converting decimal to ASCII 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 decimal to ASCII involves looking up the ASCII character corresponding to each decimal value using an ASCII table.

Conversion

Here's a step-by-step guide on how to convert decimal to ASCII:

  1. Choose the decimal value you want to convert to ASCII.
  2. Look up the ASCII character corresponding to the decimal value using an ASCII table.

Example

Let's walk through an example to illustrate the process. Suppose we want to convert the decimal value 65 to ASCII.

  1. The decimal value we want to convert is 65.
  2. We look up the ASCII character corresponding to the decimal value using an ASCII table. The ASCII character corresponding to 65 is 'A'.

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 { DecimalToAscii } from "@ilihub/code";

const decimal = 72;

const ascii = DecimalToAscii(decimal);
console.log(ascii);

// Output
// H
Enter fullscreen mode Exit fullscreen mode

References


Top comments (0)