Register
Sign In
Skip over navigation
Home
Add New Question
Jobs
Products
Calculating the sqrt of a number with 0.001 persicion
Question posted
in
Computer Software
on
04 2010
Rate question difficulty level
0
0 Votes
please write a function called Calc with takes a number and returns the sqrt of the number
in 0.001 presicion
Add an answer
Share
|
1 Answer
Gadi Berqowitz
double getSquareRoot( double x )
{
double x1 = 0.0;
double x2 = x;
double d = 1.0;
double n = 0.0;
while ( d > 0.001 || d < -0.001 )
{
n = (x2 + x1) / 2.0;
double nn = n * n;
d = nn - x;
if ( d > 0.001 )
x2 = n;
else
x1 = n;
}
return n;
}
OR
double getSquareRoot( double x1, double x2, double x )
{
double n = (x2 + x1) / 2.0;
double nn = n * n;
double d = nn - x;
if ( d < 0.001 && d > -0.001 )
return n;
if ( d > 0.001 )
x2 = n;
else
x1 = n;
return getSquareRoot( x1, x2, x );
}
double getSquareRoot( double x )
{
return getSquareRoot(0,x,x);
}
04/15/2010
Add an answer*
Your name
Email
Enter the code shown above:
please wait..
Company:
Emblaze Vcon
Location:
Israel
Occupations:
Software\System Architecture
,
Software\Web Development
add a question
Now hiring!
IT Sourcing Procurement Analyst Software Service Infrastructure
CVS Caremark
Woonsocket, RI
Strategy, including: Procurement Execution ?Maintain IT procurement process in collaboration with IT stakeholders ... legal risk mitigation strategy are addressed ?Support the development of executive briefings summarizing contract...
---------------------------
Software Development Analyst/ .NET Developer- Health IT
Northrop Grumman
Atlanta, GA
Sharp programming skills, eagerness for challenging development opportunities, and the ability to work with a ... of information security concepts and principles, as it pertains to application/service development and...
---------------------------
(IT Applications Analyst Developer Lead
Halliburton
Houston, TX
Houston, TX DUTIES: Responsible for the development, acquisition, maintenance and support of applications in assigned ... plus 7 years of progressive experience in Systems Development and Application Support, including analysis,...
---------------------------
Mgr Software Development 2-Health IT
Northrop Grumman
Little Rock, AR
and software developers. Works with members of the development team to ensure that all legacy data is ... years of relevant experience - Experience with IT Project Development Lifecycle - Experience converting data for...
---------------------------
IT Specialist (Applications Development)
Parsons
Houston, TX
in software complexity. Makes a recommendation to senior IT management and the end user. Uses charts, diagrams and ... guidance to lower-level IT staff assigned to an application development project. * Develops functional specifications to...
---------------------------
Software Development Engineer (IT Security)
Amazon.com
Seattle, WA
Role Description Amazon.com is looking for expert Software Development Engineers to develop tools supporting the IT ... for you. You will participate in every level of software development from requirements gathering to operational...
---------------------------
Software Development Engineer - Kindle with Special Offers, AmazonLocal
Amazon.com
Seattle, WA
Software Developement Engineer - Kindle Application Development, AmazonLocal AmazonLocal is looking for exceptional, ... or related field * 2+ years professional experience in software development * Fundamentals in object-oriented...
---------------------------
Manager Software Development 2-Health IT
Northrop Grumman
Little Rock, AR
and software developers. Works with members of the development team to ensure that all legacy data is ... years of relevant experience - Experience with IT Project Development Lifecycle - Experience converting data for...
Jobs
by
Simply
Hired
View all jobs