Swift 数据类型转换

来源:互联网 发布:adobeacrobat9pro mac 编辑:程序博客网 时间:2024/06/07 01:58
//数据类型转换let one : UInt8 = 1let two : UInt16 = 2000let twoToOne = two + UInt16(one)//let twoToOne = UInt8(two) + one //不允许print(twoToOne)//在swift里不允许把大的转成小的,防止精度丢失
//整型与浮点型转换let three = 3let four = 0.1456let pi = Double(three) + fourlet pii = three + Int(four)print(pi,pii)
0 0
原创粉丝点击