Sign in to follow this  
Followers 0
BALA

Imaginary Numbers

4 posts in this topic

I'm trying to find teh square root of a negative number. I have a script like this:

$x = Sqrt(-9)
MsgBox(0, "test", $x)

Though It keeps on producing "-1.#IND" but I'm expecting the imaginary number "3i"

Are imaginary numbers a limitation in the AutoIt language or am I just doing this the wrong way?


[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites



That i would guess... no normal scriptlangues knows imaginary numbers (as far as I know)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That i would guess... no normal scriptlangues knows imaginary numbers (as far as I know)

Man, what a drag. That ruins my idea for a program that will solve polynomials.

EDIT: I think I have a work around that I could use. Anyways, thanks for the help Sheville

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If you think a little outside the box. Autoit can handle them. Just use arrays with two entries one for the real and one for the imaginary part. The only thing is that you have to use functions to manipulate the variables.

Func IVAdd(ByRef arg1, ByRef arg2)
    ;Possibly check that the array is size2 and is an array
    Local $ret[2]
    $ret[0] = $arg1[0] + $arg2[0]
    $ret[1] = $arg2[1] 0 $arg2[1]
    Return $ret
EndFunc

Not as nice and cool, and fast, as it is possible to do it in C/C++ but it works. You should probably be able to find libraries you could use to on the net.

EDIT: Typo

Edited by Uten

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0