potenz lazarus / 11-Options ---------------------------------------------------------------------- Sven · 2010-08-20 15:46 i seareched the word but i cald't find something i want to use a number high another number who to do that? procedure TForm1.buttoncalculateClick(Sender: TObject); var zahl1, zahl2, zahl3, zahl4, sum1 : real; sum2 : real; begin      zahl1 := strtofloat(editkapital.text);      zahl2 := strtofloat(editjahre.text);      zahl3 := strtofloat(edittage.text);      zahl4 := strtofloat(editzins.text);      sum1 := zahl2 * 360 + zahl3;      sum2 := zahl1 * "here i wanna have the potenz"      labelsum.caption := floattostr(sum2); end;              so zahl1 thats my capital, zahl2 the days, zahl3 the years and zahl4 the interest. and this is the formula i want to use: zahl1 * (1 + zahl4 / 100)^(sum1 / 360). i wanna use that to calculate interests Please help me Sven ---------------------------------------------------------------------- theo · 2010-08-20 16:03 Do you mean function power(base,exponent : float) : float; in unit math ? ---------------------------------------------------------------------- typo · 2010-08-20 16:18 The operator to Power is a double asterisk (**). ---------------------------------------------------------------------- Sven · 2010-08-20 18:21 sorry but i don't understand you please give me an example... ---------------------------------------------------------------------- typo · 2010-08-20 18:27 Code: [Select]sum2 := zahl1 * power((1 + zahl4 / 100), (sum1 / 360)); or Code: [Select]sum2 := zahl1 * ((1 + zahl4 / 100) ** (sum1 / 360)); Sorry, I have edited the code. It seems that you have an error message from the compiler on the (^) operator for power. You will not have the message anymore if you replace it with (**). You must declare Math unit on uses clause. ---------------------------------------------------------------------- Sven · 2010-08-20 19:27 "You must declare Math unit on uses clause." Sorry but what#s that? ---------------------------------------------------------------------- typo · 2010-08-20 19:34 Hahaha. On the top of your unit there is a section called "uses" on which you must add the word "Math"; ---------------------------------------------------------------------- Sven · 2010-08-20 19:37 thanks  like this right? uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls, Math; ---------------------------------------------------------------------- typo · 2010-08-20 19:39 Yes. ---------------------------------------------------------------------- Sven · 2010-08-20 19:46 thank you very much but i have another questeion who to round the sum? because when i have bad luck than i have 20 places after the comma and i want to have 2 ---------------------------------------------------------------------- typo · 2010-08-20 20:04 Code: [Select]labelsum.caption := FloatToStrF(sum2, ffFixed, 2, 2)); After that you must make a donation, hahaha. ---------------------------------------------------------------------- Sven · 2010-08-20 20:28 Quote from: typo on August 20, 2010, 10:04:21 pmCode: [Select]labelsum.caption := FloatToStrF(sum2, ffFixed, 2, 2)); After that you must make a donation, hahaha. thank you. you had a little mistake  nicht: Code: [Select]labelsum.caption := FloatToStrF(sum2, ffFixed, 2, 2)); sondern: Code: [Select]labelsum.caption := FloatToStrF(sum2, ffFixed, 2, 2);(da war am ende ein ) zu viel) ---------------------------------------------------------------------- typo · 2010-08-20 20:32 Yes. We accept PayPal. I give you $ 10 off by surplus parentheses. ---------------------------------------------------------------------- TurboRascal · 2010-11-25 21:30 Well well, I wasn't aware '**' operator required Math unit. I thought it was a common operator just as '^' is always available in some other languages... I was wondering why the compiler throws the strange "Error: Operator is not overloaded" Thanks guys