Autor Beitrag
mexx
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 01.11.05 11:49 
Hallo,

ich möchte einen Gleitkommawert im Format 00,00 mit einem Integer-Wert multiplizieren. Wie mache ich das?

Gruß
ripper8472
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 114

Win2k (und wenn ich nen Zweitrechner haette, auch eine Linux Distri)

BeitragVerfasst: Di 01.11.05 12:00 
multiplizieren und mit format() oder wie es heisst ausgeben.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 01.11.05 12:04 
Ich kann die Multiplikation noch nicht einmal ausführen, weil es Probleme gibt Real und Integer zu Multiplizieren. Darum geht es mir.
ripper8472
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 114

Win2k (und wenn ich nen Zweitrechner haette, auch eine Linux Distri)

BeitragVerfasst: Di 01.11.05 12:07 
benutze / statt div.

edit: stuss. du willst ja multiplizieren.

schliesse mich meinem nachredner an. fehler liegt woanders.


Zuletzt bearbeitet von ripper8472 am Di 01.11.05 12:07, insgesamt 1-mal bearbeitet
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Di 01.11.05 12:07 
Dann liegt der Fehler woanders, natürlich kannst du Reals und Integers miteinander multiplizieren. Zeig mal deinen Code.

Stefan
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 01.11.05 12:07 
Das geht auf jedenfall:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  X, Z: Real;
  Y:    Integer;
begin
  X := 10.54;
  Y := 4;

  Z := X * Y;
end;



EDIT: 4 auf einmal, das gibt es ja gar nicht... :wink:

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)


Zuletzt bearbeitet von GTA-Place am Di 01.11.05 12:08, insgesamt 1-mal bearbeitet
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 01.11.05 12:07 
Warum Das ?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
  Form1: TForm1;
  A,C:Real;
  B:Integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  A:=00.01;
  B:=10;
  C:=A*B;
  Caption:=FloatToStr(C);
end;


Zu Spät !


Zuletzt bearbeitet von Blackheart666 am Di 01.11.05 12:12, insgesamt 1-mal bearbeitet
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 01.11.05 12:11 
OH ha, Sorry mein Fehler war, dass ich das Ergebnis nicht als Typ Real deklariert habe. Das das Ergebnis ebenfalls ein Kommawaert ist, konnte es ja nicht klappen. THX
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 01.11.05 12:15 
Aber wie schneide ich den Rateschwanz ab. Ich möchte nach der 2 Stelle nach dem Komma keine Zahlen mehr haben.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 01.11.05 12:18 
ausblenden Delphi-Quelltext
1:
MyZahl := RoundTo(MyZahl, -2);					

Oder eben mit Format();

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 01.11.05 12:19 
Oder Dies.

ausblenden Delphi-Quelltext
1:
Caption := FloatToStrF(C,fffixed,8,2); {Mit 8 Nachkommazahlen Rechnen - nur 2 Anzeigen}					
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Di 01.11.05 12:20 
user profile iconmexx hat folgendes geschrieben:
Aber wie schneide ich den Rateschwanz ab. Ich möchte nach der 2 Stelle nach dem Komma keine Zahlen mehr haben.


Mit RoundTo:

ausblenden Delphi-Quelltext
1:
x := RoundTo(a * i, 2);					


Möglicherweise muss der Parameter auch -2 sein, um hinter dem Komma zu Runden, schau mal in die Hilfe.

Stefan
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 01.11.05 12:22 
Wie schon gesagt vor 2 Minuten: -2

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Di 01.11.05 13:28 
Blackheart666 hat gewonnen...denoch danke an alle die geholfen habe. THX