valkk 0 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 Share this post Link to post Share on other sites
Jos 2,165 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. Share this post Link to post Share on other sites
CyberSlug 6 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! Share this post Link to post Share on other sites
SlimShady 1 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 Share this post Link to post Share on other sites
pekster 0 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. Share this post Link to post Share on other sites
SlimShady 1 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...) Share this post Link to post Share on other sites
Josbe 1 Posted August 20, 2004 Unfortunately, it's true... Really: (-1)^1 equals to 1, not indefinite... AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Share this post Link to post Share on other sites
ivan 1 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 Share this post Link to post Share on other sites
Nutster 3 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 ConsultingAn Aquarius born during the Age of AquariusAutoIt allows me to re-invent the wheel so much faster.I'm off to write a wizard, a wonderful wizard of odd... Share this post Link to post Share on other sites
Nutster 3 Posted August 24, 2004 I have submitted a fix for this problem. I expect it will appear in the unstable soon. David NuttallNuttall Computer ConsultingAn Aquarius born during the Age of AquariusAutoIt allows me to re-invent the wheel so much faster.I'm off to write a wizard, a wonderful wizard of odd... Share this post Link to post Share on other sites