summaryrefslogtreecommitdiff
path: root/243/CH4/EX4.12/4_12.sce
blob: 3c2c127c33c36e8127f7c42766b4253ac3d084f9 (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
29
30
31
32
33
34
35
36
//Example No. 4_12
//Addition of chain Numbers
//Pg No. 77
clear ; close ; clc ;

x = 9678 ;
y = 678 ;
z = 78 ;
d = 4 ;  //length of mantissa
n = max(length( string(y) ) , length(string(z)))
fy = y/10^n
fz = z/10^n
fu = fy + fz
Eu = n
if fu >= 1 then
    fu = fu/10
    Eu = Eu + 1
end
u = fu * 10^Eu
n = max(length( string(x) ) , length(string(u)))
fu = u/10^4
fx = x/10^4
fw = fu + fx
Ew = 4
if fw >= 1 then
    fw = fw/10
    Ew = Ew + 1
end
//since length of mantissa is only four we need to maintain only four places in decimal, so
fw = floor(fw*10^4)/10^4
w = fw*10^Ew
disp(w,'w = ')
True_w = 10444
ew = True_w - w
er_w = (True_w - w)/True_w
disp(er_w,'er,w = ',ew,'ew = ',True_w,'True w = ')