Calculating power and exponent in Kotlin

Hi I have to calculate power and exponent of a number in an equation, and would appreciate how to code it in Kotlin.

x = 1 - 0.9832^exp(-0.2201 x (6– 7.036)

For example in EXCEL 7^ 3 = 343, and 7^EXP(3) = 9.42427E+16

completely two different answers. I need to code to give later answer where both power and exponent are used in the equation, not power alone. It is power of the Eular’s number or constant.

Thanks for help.

Have you not found the exponential funtion while googling?
This is the Kotlin documentation on it:

Thanks. I did googled, but it doesn’t work, as both power and EXP need to be used as I said above, otherwise calculation is incorrect. So would appreciate if someone could help with this (^exp) code in kotlin.

Did you see this part of the documentation too?

yes, I did look at that as well. The issue I think is with using .pow and .exp together, It doesn’t work, and using either gives a long answer. It has to do with using Eular number.

what have you tried to put them together?

You haven’t shown any code where you use them together yet. I see no reason why it should not work. The carrot operator ^ does something completely different than exponentiation in most languages.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.