summaryrefslogtreecommitdiff
path: root/273/CH25/EX25.13/ex25_13.sce
blob: 1152138b032a72e609c2ae2e0c707d714cf3ce82 (plain)
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
clc;clear;
//Example 25.13
//calculation of sum of hexadecimal numbers

//given values
X1='C';
X2='A';
X3='E';
Y1='3';
Y2='2';
Y3='D';

//calculation
x1=hex2dec(X1);//decimal equivalent
x2=hex2dec(X2);//decimal equivalent
x3=hex2dec(X3);//decimal equivalent
y1=hex2dec(Y1);//decimal equivalent
y2=hex2dec(Y2);//decimal equivalent
y3=hex2dec(Y3);//decimal equivalent
z1=x1+y1;
z2=x2+y2;
z3=x3+y3;
Z1=dec2hex(z1);//binary equivalent of sum
Z2=dec2hex(z2);//binary equivalent of sum
Z3=dec2hex(z3);//binary equivalent of sum
disp(Z1,'sum of the first set of hexadecimal numbers is');
disp(Z2,'sum of the second set of hexadecimal numbers is');
disp(Z3,'sum of the thirdm set of hexadecimal numbers is');