Autor Beitrag
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Mo 01.12.03 20:44 
Hi,
hab wieder mal ein Problem. Guckt euch das Bild an:

www.softprose.any-ke...ompiler_error___.png

Warum kann ich nicht eine zahl durch zwei teilen wenn ich /2 verwende?

Greetz und danke für hilfe...
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mo 01.12.03 20:50 
Weil inttostr() einen Integer erwartet, beim operator / aber ein float-wert rauskommt. Du musst div anstatt / nehmen oder floattostr statt inttostr
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Mo 01.12.03 20:54 
Hä?? Also wie jetzt, wie soll ich das einbauen?

Danke für deine Antwort.
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mo 01.12.03 21:00 
Entweder
ausblenden Delphi-Quelltext
1:
inttostr(strtoint(edit1.text)*strtoint(Edit3.Text) div 2);					

oder
ausblenden Delphi-Quelltext
1:
floattostr(strtoint(edit1.text)*strtoint(Edit3.Text) / 2);					

je nachdem, ob Du Nachkommastellen brauchst (dann das 2.) oder net[/delphi]
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 01.12.03 21:05 
Weil du IntToStr benutzt. Das Ergebnis eine Fließkommadivision (mit /) ist immer eine Fließkommazahl, selbst wenn man nur 4/2 rechnet.
Da gehört also entweder noch irgendwo ein Trunc, Round oder etwas in die Richtung rein, ein "div" (für Inztegerdivision mit ganzzahligem Ergebnis) oder ein FloatToStr, die Wahl hat mal wieder der Programmierer.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Mo 01.12.03 21:07 
Ahh, danke.

Jetzt fungiert alles :-)
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mo 01.12.03 21:07 
tommie-lie hat folgendes geschrieben:
Trunc, Round oder etwas in die Richtung rein

Was ich aber nicht machen würde, schließlich wäre das ja wieder ein unnötiger Funktionsaufruf. Is ja so schon unübersichtlich genug ;-)
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 01.12.03 21:18 
UGrohne hat folgendes geschrieben:
tommie-lie hat folgendes geschrieben:
Trunc, Round oder etwas in die Richtung rein

Was ich aber nicht machen würde, schließlich wäre das ja wieder ein unnötiger Funktionsaufruf. Is ja so schon unübersichtlich genug ;-)

Ich hab' ja sowieso schon zu spät gepostet.
Sieh es als Auflistung aller Möglichkeiten, der Vollständigkeit halber ;-)

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mo 01.12.03 21:20 
tommie-lie hat folgendes geschrieben:
Sieh es als Auflistung aller Möglichkeiten, der Vollständigkeit halber ;-)

Deswegen hab ich ja (der Vollständigkeit halber) noch meinen Senf dazugegeben ;-) :lol: