Autor Beitrag
CarstenSchmidt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Do 08.09.05 19:36 
Moin!

Ich möchte einen REAL-Wert zu einem Integer wandeln. Eigentlich sollte das kein Problem sein wie in dem Beispiel

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  y  :integer;
  z  :real;

z := 1.5;
y := int(z);


Ich dachte eigentlich, dass das einfach so funktioniert aber ich bekomme immer die Meldung:

[Fehler] Unit1.pas(1105): E2010 Inkompatible Typen: 'Integer' und 'Extended'

Hat jemand eine Idee? Ich nutze D2005Prof

Schönen Abend
Carsten Schmidt
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Do 08.09.05 19:39 
'Int' ist die falsche Funktion, nimm 'Trunc'
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: Do 08.09.05 19:42 
oder round

aber nächtes mal bitte die suche bedienen danke!

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Do 08.09.05 19:44 
Trunc hat funktioniert, danke.

Warum steht aber in der Delphi Hilfe:

[Delphi] function Int(const X: Extended): Extended;
Beschreibung
In Delphi gibt Int den ganzzahligen Anteil von X zurück, also X gegen 0 gerundet. X ist ein Ausdruck des Typs Real.

Gruß
C.
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: Do 08.09.05 19:45 
du siehst doch das der rückgabeparameter von int wieder ein extended ist
dann kann es doch nicht funktionieren

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
CarstenSchmidt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Win XP, Win 2000
D6 Pers, D 2005 Prof
BeitragVerfasst: Do 08.09.05 19:49 
Ich möchte mich bei der Hilfe bedanke und mich mit einer Warnung an alle aus dem Forum verabschieden:
Nach 0,8 Promille sollte man nicht mehr programmieren! Entweder verschüttet man was oder es macht blind.

Danke und Tschüss
Carsten