• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Power of a number ?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eh Math.pow() maybe.
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java has also Math.pow function:
http://download-llnw.oracle.com/javase/6/docs/api/java/lang/Math.html#pow%28double,%20double%29
 
Abhinav Yadav
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic