# Negative bases in exponents in computation layer

I am trying to create an infinite practice for exponents and have the students pay particular attention to the difference between -2^2 vs (-2)^2.

I created code to random generate the problems but when the answers are calculated it seems to calculate the ones with a negative base incorrectly.

For example if b=-2 and 3=2 then it will calculate b^2 = -4 instead of 4.

I tried to add absolute values into the coding but it didn’t seem to “read” them.

Any ideas? (I “called” the variables on the notes page so that I could see them as I was trying to troubleshoot)

https://teacher.desmos.com/activitybuilder/custom/631628329cd45d0609c4a32a

I think it’s a quirk of `numericValue` or possibly the way the latex is parsed.

You can use
`... otherwise simpleFunction(`a^f`,`a`,`f`).evaluateAt(a,e)`

which works better. (Originally I tried `simpleFunction(`a^e`...)` but I think it treated the e as Euler’s constant instead of the variable).

1. If the base is negative and the exponent is an even number, the final product will always be a positive number.
2. If the base is negative and the exponent is an odd number, the final product will always be a negative number.

Not sure what your code is doing exactly but certainly it seems to me that Desmos is doing things correctly.