у меня есть код,строящий график функций
Код:
procedure TForm2.GrClick(Sender: TObject);
function f(x:real): real;
Var
c : real;
Begin
c :=(2*x-1)/(sqr(x-1));
f:=c;
end;
Var
a,b,x : real;
x0,y0,i : integer;
flag:boolean;
Begin
flag:=true;
x0 := line1.Width div 2;
y0 := line1.Height div 2;
With line1.Canvas do
Begin
Pen.Color:=clBlack;
MoveTo(x0,0);
LineTo(x0,line1.ClientHeight);
MoveTo(0,y0);
LineTo(line1.ClientWidth,y0);
MoveTo(0,y0);
Pen.Color := clBlue;
a :=-line1.ClientHeight div 5;
b :=-line1.ClientWidth div 15;
x :=-10;
For i:=-100 to 100 do
Begin
x:=x+0.1;
if (not((x<-0.99) and (x>-1.01))) then begin
if(flag=true) then begin
MoveTo(Trunc(x0+x*b),Trunc(y0+f(-x)*a));
flag:=false;
end;
LineTo(Trunc(x0+x*b),Trunc(y0+f(-x)*a));
end;
End;
End;
End;
procedure TForm2.line1Click(Sender: TObject);
begin
end;
procedure TForm2.ExitClick(Sender: TObject);
begin
close;
end;
end.
помогите понять почему вместо
Код:
(not((x<-0.99) and (x>-1.01)))
я не могу поставить просто -1(он крашится при -1 и работает при диапазоне)?