Sign in to follow this  
Followers 0
madflame991

MsgBox(0,'',-27^(1/3)) [SOLVED]

10 posts in this topic




#2 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

It shouldn't return -3.

Why?

Extraction Wikipedia:

The cube roots of a number x are the numbers y which satisfy the equation

Real 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

Share this post


Link to post
Share on other sites

So the answer is:

AutoIT doesn't return -3, because it isn't implemented to return cube roots of negative numbers. :evil:

MS calc.exe also doesn't.

;-))

Stefan

Your answer is misunderstandable. ;)

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 domain

Without including answers in the imaginary plane, there is no result, and it is undefined

AutoIt 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) = -27

When multiplying the initial (-3)(-3) you get positive 9 because the negatives cancel

The 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 by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/forum/index.php?showtopic=98160

The question was exactly the example I gave.

Mat

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