8 Replies - 12898 Views - Last Post: 15 January 2010 - 11:30 PM Rate Topic: -----

#1 jastin_01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-January 10

CUBE ROOT IN JAVA

Posted 14 January 2010 - 06:35 AM

Can you tell me what should i do in order to compute for the cube root of a number using java?

Super thanks in advance to anyone who could help. :)
Is This A Good Question/Topic? 0
  • +

Replies To: CUBE ROOT IN JAVA

#2 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1256
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

Re: CUBE ROOT IN JAVA

Posted 14 January 2010 - 06:39 AM

the Math.pow() function in Java takes two doubles as its arguments (which means they can be fractions). A property of exponentiation is that powers which are fractions are equivalent to nth-roots. Therefore cube roots are equivalent to raising a number to the (1/3) power.

Hope this helps.

This post has been edited by Dark_Nexus: 14 January 2010 - 06:42 AM

Was This Post Helpful? 0
  • +
  • -

#3 jastin_01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-January 10

Re: CUBE ROOT IN JAVA

Posted 14 January 2010 - 06:57 AM

hmm. is the pow function also supported in Java ME? its still not working for me..
Was This Post Helpful? 0
  • +
  • -

#4 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: CUBE ROOT IN JAVA

Posted 14 January 2010 - 09:03 AM

ME is restricted to 1.3 and the Math library has been around since 1.0

So we'd need to see your snippet to determine why "it's not working".
Was This Post Helpful? 0
  • +
  • -

#5 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 904
  • View blog
  • Posts: 3,165
  • Joined: 12-May 09

Re: CUBE ROOT IN JAVA

Posted 14 January 2010 - 10:00 AM

And what do you mean by "not working?" Does it not compile? Or is it not giving you the desired result?
Was This Post Helpful? 0
  • +
  • -

#6 chirag.jain18  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 68
  • Joined: 14-December 09

Re: CUBE ROOT IN JAVA

Posted 14 January 2010 - 10:54 PM

use Math.cbrt() function

for more functions in math class, go to http://java.sun.com/...4/tt1102.html#1
Was This Post Helpful? 0
  • +
  • -

#7 jastin_01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-January 10

Re: CUBE ROOT IN JAVA

Posted 15 January 2010 - 10:46 PM

when i said it's not working, i mean it doesn't compile.

Math.cbrt(x) and Math.pow(x,y) functions are not included in the package in Java ME. it is very limited compared to java SE.

Can you help me extract the cube root of numbers? any other idea?

i really need this function for the mobile application that i am working with.
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: CUBE ROOT IN JAVA

Posted 15 January 2010 - 11:04 PM

View Postjastin_01, on 15 Jan, 2010 - 09:46 PM, said:

when i said it's not working, i mean it doesn't compile.

Math.cbrt(x) and Math.pow(x,y) functions are not included in the package in Java ME. it is very limited compared to java SE.

Can you help me extract the cube root of numbers? any other idea?

i really need this function for the mobile application that i am working with.

Google cube root algorithm
or if you are really really lazy
Google cube root algorithm java
Was This Post Helpful? 0
  • +
  • -

#9 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: CUBE ROOT IN JAVA

Posted 15 January 2010 - 11:30 PM

Or if you are incredibly lazy and don't even want to Google: http://today.java.ne...pow-method.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1