在Swift中将Int转换为Double [英] Convert Int to Double in Swift

查看:370
本文介绍了在Swift中将Int转换为Double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

label.text = String(format:"%.1f hour", theOrder.bookingMins/60.0)

上面的代码刚得到错误:'Int' is not convertible to 'Double'

The above code just get the error:'Int' is not convertible to 'Double'

bookingMins的类型为Int,那么如何在Swift中将Int转换为Double?似乎不像C中那样简单.

bookingMins is of type Int, so how do I convert an Int to a Double in Swift? Seems not as simple as in C.

推荐答案

尝试Double(theOrder.bookingMins)

这篇关于在Swift中将Int转换为Double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆