In one of my programs i need to be able to find the square root of a number bu i cant find any easy way to do this.

Is there any easy way to find the square root?

## 20 Replies - 188074 Views - Last Post: 08 August 2010 - 08:03 PM

### #10

## Re: Square root

Posted 11 October 2005 - 09:32 AM

Math.sqrt(i)

from java.lang.Math

from java.lang.Math

### #11

## Re: Square root

Posted 11 October 2005 - 09:40 AM

Thanks!!! Works like a charm.

is there an easy way to square a number?

I have just been doing it like this (a*a).

is there an easy way to square a number?

I have just been doing it like this (a*a).

### #12

## Re: Square root

Posted 11 October 2005 - 09:40 AM

There is also a pow() function

a little bit of google goes along way:

http://stein.cshl.or....lang.Math.html

a little bit of google goes along way:

http://stein.cshl.or....lang.Math.html

### #13

## Re: Square root

Posted 12 October 2005 - 04:48 PM

isn't it Math.pow(i,2)

and the 2 means what power the i is raised to?

and the 2 means what power the i is raised to?

### #14

## Re: Square root

Posted 12 October 2005 - 05:51 PM

The qualifying path to the proper class library depends on what libraries you have imported...Math is the class library...pow() is the function within that library. And yes, in the example of pow(a,B), a is raised to the power of b.

### #16

## Re: Square root

Posted 01 April 2009 - 12:26 PM

Does anyone know how to have to square root symbol actually show up as output?

### #18

## Re: Square root

Posted 01 April 2009 - 08:13 PM

### #19

## Re: Square root

Posted 01 April 2009 - 10:11 PM

Necro'd thread.......

And, no, I don't think we can have a good square root symbol show up on the output.

And, no, I don't think we can have a good square root symbol show up on the output.

### #21 Guest_shirlz*

## Re: Square root

Posted 14 July 2010 - 04:29 AM

### #22

## Re: Square root

Posted 14 July 2010 - 05:37 AM

@shirlz: As this was already answered in an above post, please stop necroposting this thread.

### #23

## Re: Square root

Posted 14 July 2010 - 06:03 AM

extended ASCII code 251 (at least the sheet says it is) is a square root symbol. Why not just display that?

I am getting the wrong ASCII code though. Does Java have problems with extended ASCII?

int i = 4; char square = 251; double j = math.pow(i,1/2); System.out.println(square + "" i + " is " + j);

I am getting the wrong ASCII code though. Does Java have problems with extended ASCII?