Newbie: Getting square root

I’m looking for a way to calculate sqrt(4) or something like that. I took a look at Satimage255 (an osax extension) and it looks like the implemented square root. But I was wondering if people had other suggestions on how to get a square root function (outside of rolling one myself). One reason I wouldn’t want to use Satimage is that it makes the script less portable (I’d have to tell someone to download and install that before they could use my script).

Thanks!

Avery

Hi, Avery. It can be done very easily like this this:

set n to 4 -- ie. the original number
set sqrt to n ^ 0.5

:shock: Doh. I totally forgot my 8th grade math. Thanks!

In Panther:
get sqrt of 9 -->result: 3

Edit: Not a feature of Panther - see my next post below :oops:

Both forms work for any real positive number as well, and they use the same algorithm so that (sqrt of 29 - 29^.5) = 0. Further, 2.33^(1/pi) works.

I think “sqrt” is part of the Satimage osax (nothing related to Panther) :rolleyes:
Ie, if you installed Satimage, you can’t run Nigel’s example, as “sqrt” will be compiled as a command, and not as a variable name.

Oh sorry! :oops:
I didn’t remember that I had installed Satimage months ago!
I had used one time :lol:

The way n^0.5 the more customizable way anyway :wink:

My oops, too. I had forgotten about SatImage. I do have it installed.