3 Replies - 3663 Views - Last Post: 20 December 2009 - 01:14 AM Rate Topic: -----

#1 amitjena   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-December 09

Finding square root using sqrt() function

Post icon  Posted 19 December 2009 - 07:24 PM

using sqrt() when i tried finding the square root of 2 it showed result correct upto 6 places then it rounded up.
I am a maths student so how can i get the square root of 2 upto 100 places of decimal without rounding up.
Is This A Good Question/Topic? 0
  • +

Replies To: Finding square root using sqrt() function

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6644
  • View blog
  • Posts: 30,937
  • Joined: 10-May 07

Re: Finding square root using sqrt() function

Posted 19 December 2009 - 07:27 PM

There is an entire wiki site devoted to the square root of two.

Show us what you've tried & we'll gladly help out as best we can.
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Finding square root using sqrt() function

Posted 19 December 2009 - 07:45 PM

Basically you need an arbitrary precision library. Or BIGNUM library. Floating point calculations are rather limited -- they are great for most things, but no so great for calculating sqrt(2) or PI to 100's or 1000's of decimal places.

Personally I just use mathematica:
N[Sqrt[2] , 100] = 1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573


but to do so in C/C++ is really not all that hard either (most arbitrary Precision libraries have a sqrt function).
Was This Post Helpful? 0
  • +
  • -

#4 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Finding square root using sqrt() function

Posted 20 December 2009 - 01:14 AM

If you are a math's student you should think about whether C++ is the right language to be working in.

A specialised, maths rich language, like mathematica, might be more what you are looking for?
http://www.wolfram.com/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1