我怎样才能找出哪个数字更接近?假设我的值为“1”,我有两个 var,A:= 1.6 和 b:=1.001
目前正在查看一些数字并采用 0.1% +/- 差异和 +/- 0.6 差异.. 我只需要看看哪个答案更接近起始值.. 到目前为止的代码..
也没什么大不了的,代码只是为了阻止我手动完成它们:D
procedure TForm1.Button1Click(Sender: TObject);
var
winlimit,test6high,test6low,test6,test1high,test1low,test1,value: double;
begin
value := 1.0;
while value < 1048567 do
begin
test6high := value + 0.6 ;
test6low := value - 0.6 ;
test1high := (-0.1 * value)/100;
test1high := value - test1high;
test1low := (0.1 * value)/100;
test1low := value - test1low;
memo1.Lines.Add('value is '+floattostr(value)+': 1% High:'+floattostr(Test1high)+' 1% Low:'+floattostr(Test1low));
memo1.Lines.Add('value is '+floattostr(value)+': 0.6 +/- '+floattostr(Test6high)+' 0.6 Low:'+floattostr(Test6low));
memo1.Lines.Add(' ');
value := value*2;
end
end;