本文介绍了无法使用类型'($ T27,IntegerLiteralConvertible)'的参数列表调用'^'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
func FindDistance(currentLatitude: Double, currentLongtitude: Double, compareLatitude: Double, compareLongtitdue: Double) -> Double {
var dlon = compareLongtitdue - currentLongtitude
var dlat = compareLatitude - currentLatitude
let WorldRadius = 6371
var a = sin(dlat/2)^2 + cos(currentLatitude) * cos(compareLatitude) * sin(dlon/2)^2
var c = 2 * atan2(sqrt(a), sqrt(1-a))
var d = WorldRadius * c
}
println(FindDistance(11.583431,104.920141,11.584966) ,104.918569))
推荐答案
我想你想使用 pow(x,y)函数,它将x提升为y的幂。
I guess you want to use pow(x,y) function which returns x raised to the power of y.
因此,要访问此功能,您需要先导入 Darwin 并重写代码如下:
So in order to access this function you need to import Darwin first and rewrite code as follow:
import Darwin
func FindDistance(currentLatitude:Double, currentLongtitude:Double, compareLatitude:Double, compareLongtitdue:Double) -> Double {
var dlon = compareLongtitdue - currentLongtitude
var dlat = compareLatitude - currentLatitude
let WorldRadius: Double = 6371
var a = pow(sin(dlat/2), 2) + cos(currentLatitude) * cos(compareLatitude) * pow(sin(dlon/2),2)
var c = 2 * atan2( sqrt(a), sqrt(1-a) )
var d = WorldRadius * c
return d
}
这篇关于无法使用类型'($ T27,IntegerLiteralConvertible)'的参数列表调用'^'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!