Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

raising a number to an exponent

Status
Not open for further replies.

p3aul

Instructor
Jul 17, 2004
16
0
0
US
how do I do this? I have a variable of type double I would like to raise it to an exponent, also of type double. I have tried pow(base: double, exp: double) and power(base: double, exp: double). I have used lower case and I have tried capitalizing the first letter(although it shouldn't matter in Delphi). I still get that red wiggley line and a hint that says Undeclared Itentifier. I just tried a "Uses" Math in the Uses clause. That didn't work either.
Thanks,
Paul

The Bad News: Time Flies
The Good News: You are the Pilot
 
try:

Code:
 a := x^y;

the Math Power() function should be functioning though, what version of delphi are you using?

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Well I finally got Power() to work so that's the one I nee!
Thanks,
Paul

The Bad News: Time Flies
The Good News: You are the Pilot
 
Code:
 a := x^y;
found this information:
[tt]Some computer languages have a power operator that raises a value to a power. In Fortran for example the operator is ** as in 2.0**3.0 which returns 8.0. Ada also uses the ** notation and Basic uses the ^ symbol. For some reason, Pascal and C do not include this operator. That is particularly odd because Algol60, which was the ancestor of both, did have a power operator, (^). For years, the solution in Pascal has been to use a function usually given as
function Power(x, y :extended) : extended; begin result := exp(y*ln(x)); end;
The problem with that easy answer is that this function will fail (raise an exception) for a negative base value.[/tt]

quoted from:
Leslie

Have you met Hardy Heron?
 
sorry, was mixing up some languages. I'm still trying to remember where I used this syntax, but it could be from my commodore 64 days.

[morning]
/daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
LOL! I figured it was something like that.

Lately I've been typing Pascal into C++ forums...


In Pascal [tt]foo^[/tt] is the dereference operator.

[tt][small]void do_something( x, y: integer )[/small][/tt]

:-\
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top