且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Swift 中将 Float 转换为 Int

更新时间:2022-04-03 22:31:57

您可以像这样在 Swift 中将 Float 转换为 Int :

You can convert Float to Int in Swift like this:

var myIntValue:Int = Int(myFloatValue)
println "My value is (myIntValue)"

您也可以通过@paulm 的评论实现此结果:

You can also achieve this result with @paulm's comment:

var myIntValue = Int(myFloatValue)