%
% test fixed digit arithmetic
format rat;
Sum = 5/7 + 1/3;
disp(['Sum = ', num2str(Sum)]);
format short g;
a = vpa(5/7,4);
b = vpa(1/3,4);
Sum4 = vpa(a+b,4);
error4 = vpa(22/21-Sum4,20);
disp('In 4 digit arithmetic');
disp(['a = ', num2str(double(a)), ' b = ', num2str(double(b)), ' Sum = ', ...
      num2str(double(Sum4)), ', error = ', num2str(double(error4))]);
pause;
c = vpa(5/7,16);
d = vpa(1/3,16);
Sum16 = vpa(c+d,16);
error16 = vpa(22/21-Sum16,20);
disp('In 16 digit arithmetic');
disp(['c = ', num2str(double(c)), ' d = ', num2str(double(d)), ' Sum = ', ...
      num2str(double(Sum16)), ', error = ', num2str(double(error16))]);
