Autor Beitrag
Kaihnplahn
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Mo 25.07.05 18:53 
So ich hab ein groosssses Problem:

ausblenden Delphi-Quelltext
1:
Armor.Text := IntToStr(StrToInt(Fspeed.Text) / 3 );					


Dass soll der Befehl später sein!!!

Doch:
Delphi will das einfach nicht akzeptieren!!! Was muss ich einstellen damit dieser wert automatisch gerundet wird, UND dass er überhaupt funktioniert. Denn bis jettzt lässt der mich dieses Programm gar nicht erst kompilieren.

Wenn ihr noch mehr Daten braucht meldet euch bitte.

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
Moderiert von user profile iconChristian S.: Topic aus Sonstiges verschoben am Mo 25.07.2005 um 20:24
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 25.07.05 18:56 
Problem: "/" ist die normale Division, da kommt kein Integer bei raus. Um einen Integer zu erhalten, muss man das Ergebnis mit Round runden.
Alternative: nutze die ganzzahlige Division DIV. Allerdings ist 9 DIV 5 nicht 2, wie du gerne hättest, sondern 1.

_________________
We are, we were and will not be.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mo 25.07.05 19:07 
mit der funktion wäre 9 div 2 = 2

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function divit(x,y: integer): integer;
begin
  result := x div y;
  if (x mod y - y div 2) > 0 then
    result := result+1;
end;

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Kaihnplahn Threadstarter
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Mo 25.07.05 19:22 
Titel: WOW
Mann so ein GEILES Forum!!!
Innerhalb von 3 Minuten hab ich meine Antowrt gekriegt!!!
Dass soll mal ein anderes Forum nachmachen.
Den Code von uall@ogc hab ich zwar nicht ganz kapiert aber der von Gausi reicht auf jedenfall.,


DAnke nochmal vielmals
hans mans
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 38

Win XP, SuSE 10.0
D7 Pers, D2005 Pers
BeitragVerfasst: Mo 25.07.05 21:21 
Wenn man die Nachkommastellen einfach abschneiden will kann man statt mit Round zu arbeiten einfach Trunc nehmen.