# CUBE ROOT IN JAVA

Page 1 of 1

## 8 Replies - 26047 Views - Last Post: 15 January 2010 - 11:30 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=149876&amp;s=97efbf70d5b8137f6811d892b2d3dc42&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 jastin_01

• New D.I.C Head

Reputation: 0
• 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

Reputation: 1272
• Posts: 4,625
• 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

### #3 jastin_01

• New D.I.C Head

Reputation: 0
• 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..

### #4 KYA

• Wubba lubba dub dub!

Reputation: 3202
• Posts: 19,232
• 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".

### #5 xclite

• I wrote you an code

Reputation: 1264
• Posts: 4,062
• 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?

### #6 chirag.jain18

Reputation: 13
• 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

### #7 jastin_01

• New D.I.C Head

Reputation: 0
• 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.

### #8 pbl

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

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

## Re: CUBE ROOT IN JAVA

Posted 15 January 2010 - 11:04 PM

jastin_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

### #9 erik.price

• D.I.C Lover

Reputation: 486
• 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