# negative powers 8051

I am attempting to create a calculator using Keil C51 compiling for a DS89c450 target device, but I have run into an obstacle with regards to negative powers. The compiler keeps returning errors when ever I attempt to calculate the inverse of a trigonometric function and a run time error (a null response) occurs when I try negative powers. I believe the documentation states this isn't possible, is it possible with the default math.h or, if not, how would I go about achieving this?

To clarify, this is being completed in C, to assembly.

Thanks for any assistance.

• You're using the floating point version of the function? Jul 5, 2015 at 4:20
• @IgnacioVazquez-Abrams I have only tried using int/long inputs, although I have been storing the potential output (excepting the error) in a float. If you refer to a seperate function, that is, other than pow(number, power), then no, I haven't but would love to know of it. Jul 5, 2015 at 4:23
• It might have been a few years, but surely you have been shown a way to express this value with a positive exponent... Jul 5, 2015 at 4:31
• non-integer powers of a negative number are supposed to give you a domain error, but that would be a run-time error not a 'compiler error'. Please supply the smallest code fragment and exact error message that illustrates the problem. Jul 5, 2015 at 4:34
• @ChrisStratton Now that you mention it, yes, that would be entirely viable. Just didn't even think of it. More the worry is it isn't even history, I haven't even finished school yet! Jul 5, 2015 at 4:35

## 1 Answer

Negative powers are equal to the inverse of the original to the power of the absolute original value. That is to say:

x^-y = 1/x^y

With regards to inverse trigonometric functions, the inverse of a function is also known as the arc of it. eg; sin^-1 = asin cos^-1 = acos tan^-1 = atan

Thanks to Chris Stratton for that helpful reminder!