473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Square Root function

Hi guys,

For some reason, the hardware that i'm working with cannot import sqrt from math. Hence I need to manually write a sqrt function. Been searching everywhere to find such a function but to no avail.

Could any kind soul please help me with this!

THanks a million!

Sam
Feb 11 '09 #1
4 7313
bvdet
2,851 Expert Mod 2GB
Good news, Sam! Python has a built-in power operator.
Expand|Select|Wrap|Line Numbers
  1. >>> 2**2
  2. 4
  3. >>> 2**0.5
  4. 1.4142135623730951
  5. >>> 
Feb 11 '09 #2
Hi,

Thanks for replying! Unfortunately I am using python to program a Telit GSM modem. I write the program on my computer, run it on python, and it works. But as soon as I upload the program into the internal memory of the modem, things go wrong. For one, it cannot work with floats, and apparently sqrt doesn't work too.

Hence I'm trying to manually write a sqrt function to get around the problem.

Thanks for your time!

Regards,
Sam
Feb 11 '09 #3
bvdet
2,851 Expert Mod 2GB
Sam,

A google search using "square root calculation algorithm" produced a list of several web pages that explains how to calculate a square root manually.
Feb 11 '09 #4
Hi bvdet,

Thanks for your suggestions! I guess I was googling with the wrong key words that's why I didn't get anything on my first try. Anyway, I've found the webpages that you were talking about to be very useful.

Thanks a million!

Cheers, Sam
Feb 13 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: cplusplus | last post by:
Hello, I have newbie question. I'm stuck on this current assignment. Write a program that prompts the user for two integer values, passes the values to a function where they are multiplied...
2
by: Protoman | last post by:
Can you help me? For 4, my square root funct gives 4 instead of 2; here's the code: #include <iostream> #include <cstdlib> using namespace std; template<class T> T Abs(T Nbr) {
2
by: Clint Olsen | last post by:
Hello: I posted a thread on comp.programming awhile back asking about an algorithm I implemented on square root. The idea was to use the square root of a prime number as a convenient way to get...
32
by: priyam.trivedi | last post by:
Hi! Could anyone tell me how to find the square root of a number without using the sqrt function. I did it by using Newton's Formula. How can it be done by using the Binomial Theorem/Taylor...
4
by: sathyashrayan | last post by:
(This is not a home work question) Dear group, I want a program to find one number between a set of natural number.A program to guess a number in between a Natural number set.This should be a...
10
by: socondc22 | last post by:
my program is trying to use the babylonian algorithm in order to find the square root... i have a number for the number to have the square root taken of and also a number to run the loop... Whenever...
4
by: krishnai888 | last post by:
I had already asked this question long back but no one has replied to me..I hope someone replies to me because its very important for me as I am doing my internship. I am currently writing a code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.