M
M
MrDimasyan2017-05-10 19:04:30
Swift
MrDimasyan, 2017-05-10 19:04:30

How to raise to a power in Swift?

Help, please, I can not find a method that raises a variable with type Int to a power.
I draw special attention to the fact that the type Int, not Double (pow does not accept Int)
The only crutch found
var a = 2
var i = pow(Double(a),2)
BUT I'm interested without these crutches.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andrew8712, 2017-05-11
@andrew8712

This is not a crutch, but the usual type casting that is characteristic of strongly typed languages. Everything is ok with your code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question