Is there an exponent operator in Swift?

I am trying to make a payment application. Is there built-in functions for payment, interest, and principal? I have the formula for payment but how do I add an exponent to the statement? Is there an exponent operator?


Thank you

Answered by OOPer in 286583022

THere's no functions dedicated for payment, interest, and principal in the Swift Standard Library.


If your exponent operator means `^` in VB or Excel (or `**` in Fortran), you can use the `pow` function.


`pow(a, b)` is the equivalent to `a^b` in VB or Excel.


The `pow` function works on (Decimal, Int) in addition to (Double, Double). If you are planning to write an app including finaicial calculation,

you need to clarify how much calculation error would be accepted and if it it appropriate to use the `pow` function.

Accepted Answer

THere's no functions dedicated for payment, interest, and principal in the Swift Standard Library.


If your exponent operator means `^` in VB or Excel (or `**` in Fortran), you can use the `pow` function.


`pow(a, b)` is the equivalent to `a^b` in VB or Excel.


The `pow` function works on (Decimal, Int) in addition to (Double, Double). If you are planning to write an app including finaicial calculation,

you need to clarify how much calculation error would be accepted and if it it appropriate to use the `pow` function.

Thank you very much. I figured it out. My application calculates correctly but how do I convert the string to U.S. currency? I just took programming in Visual Basic but I want to write iPhone apps. I have watched a lot of hours in tutorials and I am still learing.


Thank you.

how do I convert the string to U.S. currency?

See this thread.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Is there an exponent operator in Swift?
 
 
Q