By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,768 Members | 2,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,768 IT Pros & Developers. It's quick & easy.

Square Root function

P: 13
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!

Feb 11 '09 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 2.5K+
P: 2,851
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

P: 13

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!

Feb 11 '09 #3

Expert Mod 2.5K+
P: 2,851

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

P: 13
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

Post your reply

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