Autor Beitrag
Redrah
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Fr 08.04.05 20:25 
Hallo,
Ich habe ein folgendes Problem, wenn ich 0 minus eine Zahl x rechne bekomme ich ich nicht einen Minuswert raus (was richtig wäre sondern), sondern den plus wert.
Wo ist mein Fehler? Vielen Dank für eure Hilfe
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Fr 08.04.05 20:47 
Mit welchem Datentyp rechnest du?

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Fr 08.04.05 20:52 
Mit real's
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Fr 08.04.05 21:02 
Du hast einen Fehler in deinem Code. Poste den mal hier bitte.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 08.04.05 21:19 
Vielleicht ist ja din x schon negativ ;) Probier mal -abs(x).
LH_Freak
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 385

Win XP
D7 PE, D2k5 Trial
BeitragVerfasst: Fr 08.04.05 21:23 
oder nimm if x < 0 then ShowMessage('Negativ') else ShowMessage('Positiv');
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Fr 08.04.05 22:02 
hier mein code
ausblenden Quelltext
1:
2:
3:
ergebnis1:= (zahl * zahl * zahl * zahl * zahl ) + ( 10 * (zahl * zahl * zahl * zahl ) ) + (15 * (zahl * zahl)) - ( 100 * (zahl * zahl)) + (20 * zahl) -100 ;
ergebnis2:= (5*(zahl * zahl * zahl * zahl) ) +  ( 40 * (zahl * zahl *zahl)) - (200 * zahl) + 20;
ergebnis3 := zahl - (ergebnis1 / ergebnis2);
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 08.04.05 22:09 
Und mit welchen Zahlen?
Ganz offensichtlich kann ja ergebnis1 / ergebnis2 sehr gut auch negativ werden.
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Fr 08.04.05 22:20 
naja wenn man für x=0 einsetzt dann kommt da raus 0 - 5 = 5 was ja nicht stimmen kann
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 08.04.05 22:38 
zahl=0 => ergebnis1=-100 => ergebnis2=20
=>ergebnis1/ergebnis2 = -5
0 - (-5) = 0 + 5 = 5

Minus minus = plus, falls dir das nicht bewusst ist.
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Fr 08.04.05 22:41 
okay soorry ^^
ich habe das vorher schriftlich gerechnet und habe das minus beim rechnen vergessen :lol:
und deswegen dachte ich die ganze Zeit es kann doch nicht stimmen ^^
also nochmal sorry, aber danke für deine hilfe :wink: