valkk Posted August 20, 2004 Share Posted August 20, 2004 (edited) I keep getting -1.#IND as a result for raising a negative number to a power. Positive numbers work, but negative don't. 4^2=16 3^3=27 (-4)^2=16 ( I get 1.#IND ) (-3)^3=-27 ( I get 1.#IND ) Ironicly if you calculate it manually in autoit, it works ^^. (-4)*(-4)=16 (-3)*(-3)*(-3)=-27 Makes no sense. Why is this and how do I get around it? You can't square root a negative number, but you can sure raise it to a power. Edited August 20, 2004 by valkk Link to comment Share on other sites More sharing options...
Developers Jos Posted August 20, 2004 Developers Share Posted August 20, 2004 I keep getting -1.#IND as a result for raising a negative number to a power. (-4)^2=16 ( I get 1.#IND ) <{POST_SNAPBACK}>and it does work when you do: 0-4^2 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
CyberSlug Posted August 20, 2004 Share Posted August 20, 2004 and it does work when you do: 0-4^2 <{POST_SNAPBACK}>Wouldn't the order of operations make that: 0 - ( 4 ^ 2) ?? Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
SlimShady Posted August 20, 2004 Share Posted August 20, 2004 Wouldn't the order of operations make that: 0 - ( 4 ^ 2) ?? <{POST_SNAPBACK}>No, I think he means (0 - 4) ^ 2 Link to comment Share on other sites More sharing options...
pekster Posted August 20, 2004 Share Posted August 20, 2004 No, I think he means (0 - 4) ^ 2 <{POST_SNAPBACK}>Sure, that is what he means, but it too fails just the same as (-4) ^ 2 fails. Try this: $ret = (0 - 4) ^ 2 MsgBox(0, "", $ret) Same problem. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
SlimShady Posted August 20, 2004 Share Posted August 20, 2004 True... I wonder why.... Because I assumed that AutoIt handles all math. (Can't make a good English sentence of it...) Link to comment Share on other sites More sharing options...
Josbe Posted August 20, 2004 Share Posted August 20, 2004 Unfortunately, it's true... Really: (-1)^1 equals to 1, not indefinite... AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
ivan Posted August 21, 2004 Share Posted August 21, 2004 (edited) If we remember our algebra lessons, raising an expression x to a negative power is equivalent to dividing 1 by your x expression. However, if your x expression reaches a zero value, your division will not be defined, so, one way of solving your problem is to divide 1 by your x expression and making sure X does not reach a zero value.IVAN Edited August 21, 2004 by ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3 Link to comment Share on other sites More sharing options...
Nutster Posted August 23, 2004 Share Posted August 23, 2004 0-4^2 will do the power first (remember order of operations) and then the subtraction. That is, 0 - (4^2) = 0 - 16 = -16. Hmm, Negative numbers to integer powers should work, but they do not. The problem comes from the situation when a negative is raised to a non-integer power. The results can be quite complex (as in the complex number set). I will check what is happening and see if I can improve it. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Nutster Posted August 24, 2004 Share Posted August 24, 2004 I have submitted a fix for this problem. I expect it will appear in the unstable soon. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now