Autor Beitrag
Flamefire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 11.08.09 17:13 
Hab folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
    PositionInt:Word;//...
    Data.X:=Floor(ASingle /10)+(((LOBYTE(PositionInt)-$87)*3shl 6);


und ein Kumpel meinte, er bekommt da gelegendlich Exceptions

und hat das geändert zu:
ausblenden Delphi-Quelltext
1:
2:
    PositionInt:Word;//...
    Data.X := Floor((LOBYTE(PositionInt) * 3 - $195) *64 + (ASingle / 10));

das sollte aber meiner meinung nach äquivalent sein, und wenn im ersten fall exceptions kommen, dann auch im 2.
nur sollte der obere code u.U. etwas schneller sein

ist das möglich?
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Di 11.08.09 17:51 
Was für eine Exception? Welcher Wertebereich haben die beiden Variablen in deiner Applikation?
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 11.08.09 18:10 
"Invalid floating point operation"

X:Integer;
ASingle:Single;<-- wird vorher zugewiesen

fehler kommt anscheinend bei Floor(ASingle/10)