Autor Beitrag
Caesar44
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: So 07.12.08 12:28 
Hi an alle im Delphiforum, ich wünsche euch allen erstmal nen schönen 2. Advent!
Ich habe allerdings ein Problem mit meinem Delphiprogramm mittels man dem eine Wurzel bestimmen können soll:
Dies ist auch mirt der repeatschleife kein Problem. Allerdings kann ich scheinbar in dem until Bereich keine zwei Bedingungen mit OR verknüpfen
Dann kommt immer: Operator kann nicht angewendet werden.
Das Programm funktioniert nach dem Bisektorenverfahren(Ich meine es heißt so)


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure Tlbl_StartwertNEG.BerechneClick(Sender: TObject);
Var
  Startwert1, Startwert2, Mittelwert, Funktionswert, E, Quadrat : real;
begin
  Startwert1 := StrToFloat(edt_Startwert1.text);
  Startwert2 := StrToFloat(edt_Startwert2.text);
  E               := StrToFloat(edt_E.text);
  Quadrat    := StrToFloat(edt_Wurzelaus.text);
  repeat
    Mittelwert:= (Startwert2+Startwert1)/2;
    Funktionswert:=(Mittelwert*Mittelwert);
    If Funktionswert - Quadrat > 0
    then
      Startwert2:=Mittelwert
    else
      Startwert1:=Mittelwert
  until ABS(Funktionswert -Quadrat) < E;  // Hier hätte ich gerne noch den OR Operator, der sagt dass ABS(...) auch Null sein kann
  pnl_wurzelausgabe.caption := FloatToStr(Mittelwert);
end;

end.


MfG Caesar44

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: So 07.12.08 12:49 
In diesem Fall kannst du einfach <= für "kleiner oder gleich" schreiben. Doch nicht... :oops:

Bei der Verwendung von OR musst du Klammern um die einzelnen Bedingungen machen, also beispielsweise Until (a < b) OR (c = d).


Zuletzt bearbeitet von nagel am So 07.12.08 12:54, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 07.12.08 12:50 
ausblenden Delphi-Quelltext
1:
until (Abs(Funktionswert - Quadrat) < E) or (Abs(Funktionswert - Quadrat) = 0);					
Caesar44 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: So 07.12.08 12:54 
Vielen Dank!

mfG Caesar44