//变量var str = "Hello,playground"var dd = 23var PI = 3.14var uu = truevar me = ("me",11,"33")me.0me.1me.2PI = 3.122.常量
//常量let m = 89let u = falsevar a:Intvar b:Stringprint(a) //a 还没有初始化,不能使用3.int、float、double
Int.min //-9223372036854775808Int.max //9223372036854775807Int64.min //-9223372036854775808Int64.max //9223372036854775807let f = 15 //15let fa = 0xF //15let fb = 0o17 //15let fc = 0b1111 //15let fd = 1_000_000 //1000000var oneThirdint = 1/3 //默认类型int,0var oneThirdfloat:float = 1/3 //小数点后有7位,0.3333333var oneThirdDouble:Double = 1/3 //小数点后有16位,0.3333333333333333print(oneThirdint) //0\nprint(oneThirdfloat) //由打印可知,精确度为小数点后6位,0.333333\nprint(oneThirdDouble) //精确度为小数点后15位,0.333333333333333\n4.查看推导类型type(of:XXX)
var three = 3type(of:three) //查看推导结果,Int.Typevar z = 0.14type(of:z) //Double.Typevar PI = 314e-2 //3.14PI = 3 + 0.14159 //3.14159PI = Double(three) + z // 不同类型变量不能直接加减,要先类型转换,3.14总结
以上是内存溢出为你收集整理的swift3-常量与变量,int、float、double,类型推导全部内容,希望文章能够帮你解决swift3-常量与变量,int、float、double,类型推导所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)