Recent

Author Topic: potenz  (Read 17230 times)

Sven

  • New Member
  • *
  • Posts: 16
potenz
« on: August 20, 2010, 05:46:34 pm »
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
« Last Edit: August 20, 2010, 05:52:12 pm by Sven »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1945
Re: potenz
« Reply #1 on: August 20, 2010, 06:03:26 pm »
Do you mean
function power(base,exponent : float) : float;
in unit math ?


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: potenz
« Reply #2 on: August 20, 2010, 06:18:07 pm »
The operator to Power is a double asterisk (**).

Sven

  • New Member
  • *
  • Posts: 16
Re: potenz
« Reply #3 on: August 20, 2010, 08:21:43 pm »
sorry but i don't understand you please give me an example...

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: potenz
« Reply #4 on: August 20, 2010, 08:27:14 pm »
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.
« Last Edit: August 20, 2010, 09:05:27 pm by typo »

Sven

  • New Member
  • *
  • Posts: 16
Re: potenz
« Reply #5 on: August 20, 2010, 09:27:29 pm »
"You must declare Math unit on uses clause."

Sorry but what#s that?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: potenz
« Reply #6 on: August 20, 2010, 09:34:04 pm »
Hahaha.

On the top of your unit there is a section called "uses" on which you must add the word "Math";

Sven

  • New Member
  • *
  • Posts: 16
Re: potenz
« Reply #7 on: August 20, 2010, 09:37:42 pm »
thanks  :D

like this right?

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, Math;

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: potenz
« Reply #8 on: August 20, 2010, 09:39:15 pm »
Yes.

Sven

  • New Member
  • *
  • Posts: 16
Re: potenz
« Reply #9 on: August 20, 2010, 09:46:16 pm »
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

  • Hero Member
  • *****
  • Posts: 3051
Re: potenz
« Reply #10 on: August 20, 2010, 10:04:21 pm »
Code: [Select]
labelsum.caption := FloatToStrF(sum2, ffFixed, 2, 2));
After that you must make a donation, hahaha.
« Last Edit: August 20, 2010, 10:17:57 pm by typo »

Sven

  • New Member
  • *
  • Posts: 16
Re: potenz
« Reply #11 on: August 20, 2010, 10:28:39 pm »
Code: [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

  • Hero Member
  • *****
  • Posts: 3051
Re: potenz
« Reply #12 on: August 20, 2010, 10:32:03 pm »
Yes.

We accept PayPal.

I give you $ 10 off by surplus parentheses.
« Last Edit: August 20, 2010, 10:55:36 pm by typo »

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: potenz
« Reply #13 on: November 25, 2010, 10:30:23 pm »
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 ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

 

TinyPortal © 2005-2018