% Script File: FpFacts
% Prints some facts about the underlying floating point system.

clc

% p = smallest positive integer so 1+1/2^p = 1.
x=1; p=0; y=1; z=x+y;
while z>1
y=y/2;
p=p+1;
z=1+y;
end
fprintf('p = %2.0f is the smallest positive integer so 1+1/2^p = 1.\n\n',p)

% q = smallest positive integer so 1/2^q = 0.
x=1; q=0;
while x>0
x=x/2;
q=q+1;
end;
fprintf('q = %2.0f is the smallest positive integer so 1/2^q = 0.\n\n',q)

% r = smallest positive integer so 2^r = inf.
x=1; r=0;
while x~=inf
x=2*x;
r=r+1;
end
fprintf('r = %2.0f is the smallest positive integer so 2^r = inf.\n\n',r)