File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Powers and the math. class

 
Peter Shipway
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to perform the following formula 1-(1+i)(power)-n
I know that i need to use the Math. class but im not sure on which one, i have tired maths.Floor and it didnt work (got a negative number) any help would be great as always .
 
Tim West
Ranch Hand
Posts: 539
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say you're looking for the static method Math.pow(). It works with positive or negative numbers.
...Assuming 'i' in your formula above isn't a reference to complex numbers, that is
--Tim
 
John Smith
Ranch Hand
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to perform the following formula 1-(1+i)(power)-n
This doesn't look like a mathematical expression that I can parse, but I think you have a compounded interest in mind:
1 - (1 + i)^(-n)
If so, the corresponding Java code would be:

For more information, see the javadocs for the pow() method of the Math class
 
Peter Shipway
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup im thinking compound interest, sorry shoulda said that, ah so its .pow i thought i couldnt use that because i was using ints not doubles lol, well looks like im still n00b rock on d0de!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic