(re;) Math.pow Question

From: Michael B. Williams (mbw4359_at_yahoo.com)
Date: 05/30/04


Date: 29 May 2004 20:16:27 -0700

Ooooopppps and sorry about the sniplet thanks again

 /* and if this helps I using JCreator and j2sdk1.4.2_04 */
 
 double
 interest = .0575,
 J = 0,
 
 N = 360, /* I had zero */

 ftemp;

 J = interest / 1200 ;
 ftemp = ( 1-(1+J) );
 N = N * (-1);

 // N would be -360
 System.out.println( Math.pow( ftemp , N ) );

"Michael B. Williams" <mbw4359@yahoo.com> wrote in message
news:5f2e7e38.0405291003.7db11c16@posting.google.com...
> Please help
>
> The Math.pow call is retuning Infinity? What am I doing wrong - be
> gental I java newbie. Thanks in advance
>
> import java.math.*;
>
>
> double
> interest = .0575,
> J = 0,
> N = 0,
> ftemp;
>
> J = interest / 1200 ;
> ftemp = ( 1-(1+J) );
> N = N * (-1);
>
> System.out.println( Math.pow( ftemp , N ) );

My result is 1.0, which seems reasonable to me since your exponent is -0.0:
is this the exact code that produces Infinity? By my reckoning, x^(-y) ==
1/(x^y), so you have ftemp^(-0) == 1/(ftemp^0) == 1/1 == 1. The expected

Michael B. Williams wrote:
> The Math.pow call is retuning Infinity? What am I doing wrong - be
> gental I java newbie. Thanks in advance

When I compile and run your code, I get 1.0 as the answer, not Infinity.
That's the result I'd expect. If you're still getting 1.0, then I
suspect that's not the code that you're compiling or running. Are you
sure you aren't running an older version of the code by mistake?

-- 
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation