Autor Beitrag
phil_!
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Do 16.06.05 17:18 
Also: Folgendes Problem: ich möchte sowas schreiben a^b (a hoch b), die Variablen habe ich auch schon davor definiert und so, aber immer wenn ich das mit dem ^ mache, dann kommt wenn ich auf RUN klicke folgende Fehlermeldung: "[Error] Unit1.pas(50): Pointer type required"

Was muss ich jetzt machen?

danke :D

mfg
phil


Moderiert von user profile iconChristian S.: Topic aus Sonstiges verschoben am Do 16.06.2005 um 19:14
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Do 16.06.05 17:20 
^ ist in Delphi kein "hoch", sondern ein Referenzierungsoperator (Hat was mit Zeigern zu tun).

a^b kannst du mit Exp(b * Ln(a)) berechnen.

AXMD
phil_! Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Do 16.06.05 17:23 
Na dann kein Wunder^^.

Danke!!! Echt netter Support hier im Forum! :D

mfg
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 16.06.05 18:13 
user profile iconAXMD hat folgendes geschrieben:
a^b kannst du mit Exp(b * Ln(a)) berechnen.
Ich würde da eher power in der Unit Math empfehlen, sonst bekommt man ein Problem mit einem a<=0, wenn man das in einen Logarithmus stopft. ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 16.06.05 18:18 
Das Power dürfte evtl. sogar schneller laufen, da er kein Logarithmus durchführen muss.
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Do 16.06.05 23:47 
Also das ist bestimmt nicht schneller:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function Power(const Base, Exponent: Extended): Extended;
begin
  if Exponent = 0.0 then
    Result := 1.0               { n**0 = 1 }
  else if (Base = 0.0) and (Exponent > 0.0) then
    Result := 0.0               { 0**n = 0, n > 0 }
  else if (Frac(Exponent) = 0.0) and (Abs(Exponent) <= MaxInt) then
    Result := IntPower(Base, Integer(Trunc(Exponent)))
  else
    Result := Exp(Exponent * Ln(Base))
end;
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 17.06.05 08:31 
Vor allem darf auch base nicht kleiner oder gleich Null sein!

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 17.06.05 08:57 
*Mist*, dann ist Power doch nicht schneller :wink: . Aber IntPower dürfte schneller sein als Exp(a*ln(b)), da IntPower nur noch auf Assembler basiert, also keine Verzeigungen zu anderen Prozeduren hat.