Square root

is there any easy way?

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 171219 Views - Last Post: 08 August 2010 - 08:03 PM Rate Topic: -----

#1 Drift-O-Manaic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 19-August 05

Square root

Post icon  Posted 11 October 2005 - 09:30 AM

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?
Is This A Good Question/Topic? 0
  • +

#10 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Re: Square root

Posted 11 October 2005 - 09:32 AM

Math.sqrt(i)

from java.lang.Math
Was This Post Helpful? 1

#11 Drift-O-Manaic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 19-August 05

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).
Was This Post Helpful? 0
  • +
  • -

#12 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

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
Was This Post Helpful? 0
  • +
  • -

#13 cheezit  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 09-October 05

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?
Was This Post Helpful? 1

#14 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

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.
Was This Post Helpful? 0
  • +
  • -

#15 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Square root

Posted 13 October 2005 - 12:56 AM

There's also an approximation method.
See this snippet here.

It's not Java Code but it will be with little modifications....but i figure you will at least get the algorithm right.
Was This Post Helpful? 0
  • +
  • -

#16 Kevin137  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 23-January 08

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?
Was This Post Helpful? 0
  • +
  • -

#17 Kevin137  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 23-January 08

Re: Square root

Posted 01 April 2009 - 12:46 PM

On a PC that is, not a a Mac
Was This Post Helpful? 0
  • +
  • -

#18 pbl  Icon User is offline

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

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

Re: Square root

Posted 01 April 2009 - 08:13 PM

View PostDrift-O-Manaic, on 11 Oct, 2005 - 08:40 AM, said:

Thanks!!! Works like a charm.

is there an easy way to square a number?

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

But if you really want to sqare... this is the easy one
Use pow() if the exposant is a floating number
Was This Post Helpful? 0
  • +
  • -

#19 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Square root

Posted 01 April 2009 - 10:11 PM

Necro'd thread.......:angry:

And, no, I don't think we can have a good square root symbol show up on the output.
Was This Post Helpful? 0
  • +
  • -

#20 priya_lorha  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 78
  • Joined: 02-August 08

Re: Square root

Posted 02 April 2009 - 01:24 AM

Yes, Maths.sqrt(number)
Was This Post Helpful? 1

#21 Guest_shirlz*


Reputation:

Re: Square root

Posted 14 July 2010 - 04:29 AM

View Postcheezit, on 12 October 2005 - 03:48 PM, said:

isn't it Math.pow(i,2)
and the 2 means what power the i is raised to?

Was This Post Helpful? 0

#22 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10466
  • View blog
  • Posts: 38,786
  • Joined: 27-December 08

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. :)
Was This Post Helpful? 0
  • +
  • -

#23 Luckless  Icon User is offline

  • </luck>
  • member icon

Reputation: 292
  • View blog
  • Posts: 1,146
  • Joined: 31-August 09

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?
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?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2