Power function

Luiz

Board Regular
Joined
Mar 12, 2004
Messages
63
Hi,

Anybody knows what is the difference between both codes and why the second one results in an error?

Public Sub Cardano1()
x = WorksheetFunction.Power(((-1 - Sqr(1)) / 2), 1 / 3)
End Sub

Public Sub Cardano2()
x = ((-1 - Sqr(1)) / 2) ^ (1 / 3)
End Sub

Thanks in advance,

Luiz
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi Luiz

You can find it in the help.

In this case, when you use the "^" operator with the exponent 1/3, you cannot use a negative number as the base.

That's why you have the error.

From the help on the "^" operator:

^ Operator
Used to raise a number to the power of an exponent.
Syntax
result = number^exponent


Remarks
A number can be negative only if exponent is an integer value. When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top