madflame991 Posted December 10, 2009 Share Posted December 10, 2009 (edited) Try this: MsgBox(0,'',-27^(1/3)) It should return -3... Edited December 10, 2009 by madflame991 Game Game Gadget! - read about indie games, gadgets, chiptunes and demoscenesAssembly-like language interpreter and custom machine emulatorSuper Mario Screen Mate - official website or autoit forum pageCogut - Puzzle Game + Editor like sokoban and others Link to comment Share on other sites More sharing options...
water Posted December 10, 2009 Share Posted December 10, 2009 (edited) I'm not good at math (anymore) but isn't this the cube root of -27? And I think the root of a negative number isn't defined in AutoIt. Edited December 10, 2009 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
99ojo Posted December 10, 2009 Share Posted December 10, 2009 Hi, it should indeed. I don't know if it is really a bug, the dev's should decide. MsgBox(0,'',-(27^(1/3))) ;-)) Stefan Link to comment Share on other sites More sharing options...
jvanegmond Posted December 10, 2009 Share Posted December 10, 2009 It shouldn't return -3. github.com/jvanegmond Link to comment Share on other sites More sharing options...
99ojo Posted December 10, 2009 Share Posted December 10, 2009 It shouldn't return -3.Why?Extraction Wikipedia:The cube roots of a number x are the numbers y which satisfy the equationReal numbers........If x and y are real, then there is a unique solution and so the cube root of a real number is sometimes defined by this equation. If this definition is used, the cube root of a negative number is a negative number. The principal cube root of x is also represented by.......http://en.wikipedia.org/wiki/Cube_root Stefan Link to comment Share on other sites More sharing options...
jvanegmond Posted December 10, 2009 Share Posted December 10, 2009 I'm not talking about whether it should in mathematics, this is AutoIt. A programming language. github.com/jvanegmond Link to comment Share on other sites More sharing options...
99ojo Posted December 10, 2009 Share Posted December 10, 2009 So the answer is: AutoIT doesn't return -3, because it isn't implemented to return cube roots of negative numbers. MS calc.exe also doesn't. ;-)) Stefan Your answer is misunderstandable. Link to comment Share on other sites More sharing options...
NerdFencer Posted December 10, 2009 Share Posted December 10, 2009 (edited) Manadar is thinking of the square root of a negative number such as(-9)^(1/2)to which the answer would be 3i if including answers outside the real domainWithout including answers in the imaginary plane, there is no result, and it is undefinedAutoIt does not support mathematics in the non-real plane and therefore it cannot find the even root of a negative number, but should be able retrieve the odd root of a negative number assuming that it supports all basic arithmetic in the real plane.For(-27)^(1/3)You are taking the CUBE root of a negative number.The answer is -3 because:(-3)(-3)(-3) = -27When multiplying the initial (-3)(-3) you get positive 9 because the negatives cancelThe third -3 reintroduces the negative, making the expression negative.I personally would call the undefined result a bug, but one that is probably not worth fixing.If you really want math outside the real domain, I suggest writing a UDF for it.Edit: typo Edited December 10, 2009 by NerdFencer _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
madflame991 Posted December 10, 2009 Author Share Posted December 10, 2009 I personally would call the undefined result a bug, but one that is probably not worth fixing.If you really want math outside the real domain, I suggest writing a UDF for it.I agree. It would eventually slow down the arithmetic evaluator. Game Game Gadget! - read about indie games, gadgets, chiptunes and demoscenesAssembly-like language interpreter and custom machine emulatorSuper Mario Screen Mate - official website or autoit forum pageCogut - Puzzle Game + Editor like sokoban and others Link to comment Share on other sites More sharing options...
Mat Posted December 10, 2009 Share Posted December 10, 2009 http://www.autoitscript.com/forum/index.php?showtopic=98160 The question was exactly the example I gave. Mat AutoIt Project Listing 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