a=0;
b=2;
f[x_]:=N[x^2-2];
epsilon = .0001;
c=N[(a+b)/2];
d=f[c];
For[n=1 , b-a >epsilon, c=N[(a+b)/2]; d=f[c], a=N[If[d>0,a,c]]; b=N[If[d>0,c,b]]; Print[a,"  ",b]]
Print[c,"  ",f[c]]

a=-1;
b=2;
f[x_]:=N[Abs[x]/x];
epsilon = .001;
c=N[(a+b)/2];
d=f[c];
For[n=1 , b-a >epsilon, c=N[(a+b)/2]; d=f[c], a=N[If[d>0,a,c]]; b=N[If[d>0,c,b]]; Print[a,"  ",b]]
Print[c,"  ",f[c]]