So long story short I need to get x to the power of y which are both doubles
Problem is I keep getting 0
import Darwin
x: Double = 3.86
y: Double = 4.86
var Answer = Int(pow(Double(x),Double(y)))
// Answer = 0?
// Answer Should = 709.2744...
So why is this the case and how do I make this actually work?
and yes this calculation works fine with Integers just the second Doubles get added to the mix it just all falls apart
CodePudding user response:
var x: Double = 3.86
var y: Double = 4.86
var Answer = Double(pow(x, y))
print(Answer)