• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Power of a number ?

 
Abhinav Yadav
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can we directly find the power of a number in java ,as in C language there is a function math.pow() is any such type of function provided by java?
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eh Math.pow() maybe.
 
Ireneusz Kordal
Ranch Hand
Posts: 423
 
Abhinav Yadav
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:Eh Math.pow() maybe.

thanks
it worked
but what should i do to make all the numbers to be printed and not the exponential part
eg if i did

what should be done to print the exact no. i.e
548815620517731830194541.899025343415715973535967221869852721
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try to search for it? Because one maybe a couple searches and you'll find the answer.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:Why don't you try to search for it? Because one maybe a couple searches and you'll find the answer.
Hint: The double you are using is a "primitive type". If you find the Java™ Tutorials, there is a section about primitive types and it gives a hint for exactly what you want there.
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abhinav yadav wrote:but what should i do to make all the numbers to be printed and not the exponential part
eg if i did

what should be done to print the exact no. i.e
548815620517731830194541.899025343415715973535967221869852721

Switch to BigDecimal. That's the only class in the core API that fully preserves full precision.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic