Autor Beitrag
der_häuptling
ontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 73

Win XP
Delphi 2005 Pers
BeitragVerfasst: Sa 23.04.05 17:08 
Hallo alle

ich möchte im Code sagen, dass das Programm von der eingegebenen Zahl die Wurzel zieht.
Ich hab schon nach Hilfe gesucht, aber keine gefunden:

der_häuptling


Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am Sa 23.04.2005 um 17:09
Konna
Hält's aus hier
Beiträge: 13

Win ME, WIN 2000, WinXP, SuSE 8
D2005
BeitragVerfasst: Sa 23.04.05 17:12 
da gibt es zwei möglichkeiten, zum einen kannst du die Quadratwurzel mit

ausblenden Delphi-Quelltext
1:
sqrt(x)					


ziehen, die alternative ist einfach eine potenz mit hoch 1/y zu schreiben

Quadratwurzel: power(x,1/2)
irgendeine Wurzel: power(x, 1/y)

Anmerkung: Math unter uses hinzufügen
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 23.04.05 17:26 
Wwobei sqrt(x) schneller ist als power(x, 0.5), soweit ich weiß. Außerdem musst du für Power die Unit Math noch einbinden.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 23.04.05 18:55 
Ja, sqrt ist schneller als power. Für sqrt gibt es einen direkten Befehl für die FPU. Mit power braucht es ein paar ifs, ne Multiplikation, Logarithmus und die Exponentialfunktion. Ausserdem wird sqrt im Code inline gerechnet (im Gegensatz zu power).
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 23.04.05 19:21 
Was meinst du mit inline?
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 23.04.05 19:23 
Es wird im Assemblercode gar keine Funktion aufgerufen.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 23.04.05 19:33 
she ich das richtig? du meinst die Compilermagic?

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 23.04.05 19:39 
Richtig ... Die meint er, wobei selbst die Compiler-Magic nicht alles inline rechnet (z.B. Trunc), aber das ist ne andere Geschichte.

Ansonsten: Für sehr große Zahlen gibt es konkrete Algos, die linear bis quadratisch die Berechnung durchführen. Hab selbst grad einen solchen für QBasic rumliegen, der aber ohne Weiteres nach Delphi propertier werden kann (poste ich auf Anfrage).

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 23.04.05 19:42 
Ja; obwohl man ab Delphi 2005 inline Prozeduren auch selbst schreiben kann. Da wäre sowas auch ohne Compiler Magic möglich. Ich glaub früher waren inline assembler Prozeduren auch möglich. Offenbar geht das aber nicht mehr. Bis eben Delphi 2005.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 23.04.05 19:48 
soll das heissen, die kicken den praktischen assembler raus??? niemals! wozu versuch ich grad asm zu lernen? :shock:

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 23.04.05 19:52 
Obwohl dieser Post überhaupt nichts mit dem Thema zu tun hat:
@JayEff: Inline Prozeduren und Funktionen sind eine gute Sache. Endlich kann man mit gutem Gewissen richtig objektorientiert programmieren: Getter- und Setter- Funktionen (im Zusammenhang mit properties) sind jetzt ohne schlechtes Gewissen möglich (nicht, dass es bis jetzt ein seriöses Problem war, aber trotzdem ;)). C++ kann ja das schon lange.
der_häuptling Threadstarter
ontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 73

Win XP
Delphi 2005 Pers
BeitragVerfasst: So 24.04.05 18:44 
Titel: ----
Hi Leute,

vorab danke für die Hilfe. Eine Sache brauch ich dazu aber noch: Ihr habt ja gesagt, dass man beim sqrt(x) noch so anderes Zeug braucht.... Ich programmiere jetzt seit 4 Tagen mit Delphi un habe davon so viel Ahnung wie in Hund vom Eier legen....
Kennt ihr ein tut, wo das, was man für sqrt(x) braucht, beschrieben steht. Für noch mehr Hilfe wäre ich echt dankbar!!!

der_häuptling
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: So 24.04.05 18:56 
Ich glaub du hast uns falsch verstanden. Wenn du sqrt nimmst brauchst du nix zusätzlich machen. Wenn du aber Power nimmst musst du die Unit Math einbinden.

PS: Warum sollte es ein Tutorial für einen einfachen Befehl geben?
der_häuptling Threadstarter
ontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 73

Win XP
Delphi 2005 Pers
BeitragVerfasst: So 24.04.05 19:00 
Titel: -
Ja, jetzt hab ich es auch gesehen. Hab eigentlich gemient, ob es für Math Unit ein tut gibt, oder ob es wenigstens in einem vorkommt. Kennst du eins?

der_häuptling
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: So 24.04.05 19:04 
Ich kenne keins, aber es reicht wenn du dir in der Delphi-Hilfe danach suchst, und dir dann die Befehle, die es dort gibt anguggst. Die sind auch relativ gut erklärt (im Verhältnis zu einigen Erklärungen).

PS: Ich hoffe du weist wie du dir die Unit raussuchst in der Delphi-Hilfe?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 24.04.05 20:13 
ich würde dir empfehlen dir mal den CrashKurs, den Christian hier vor kurzem gepostet hat, durchzulesen, da müsstest du alles wesentliche finden.

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)