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

## Recommended Posts

Try this:

`MsgBox(0,'',-27^(1/3))`

It should return -3...

##### Share on other sites

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:

##### 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 on other sites

It shouldn't return -3.

##### 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 on other sites

I'm not talking about whether it should in mathematics, this is AutoIt. A programming language.

##### Share on other sites

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

MS calc.exe also doesn't.

;-))

Stefan

##### Share on other sites

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.

(-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 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 on other sites

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

The question was exactly the example I gave.

Mat

## Create an account

Register a new account

×

• Wiki

• Back

• Git