blob: df0b66d4c52a6f7fb29eb90d79c150889df5bcaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
//Example No. 4_04
//Rounding-Off
//Pg No. 66
clear ; close ; clc ;
fx = 0.7526
E =3
gx = 0.835
d = E - (-1)
//Chopping Method
Approx_x = fx*10^E
Err = gx*10^(E-d)
mprintf('\n Chooping Method : \n Approximate x = %.4f*10^%i \n Error = %.4f \n ',fx,E,Err)
//Symmetric Method
if gx >= 0.5 then
Err = (gx -1)*10^(-1)
Approx_x = (fx + 10^(-d))*10^E
else
Approx_x = fx*10^E
Err = gx * 10^(E-d)
end
mprintf('\n Symmetric Rounding :\n Approximate x = %.4f*10^%i \n Error = %.4f \n ',fx + 10^(-d),E,Err)
|