Kotlin 数据类型(数值类型)
Kotlin 的常见数据类型:
类型 |
范围 |
byte |
-128~127 |
short |
32767 |
int |
-2147483648~2147483647 |
long |
9223372036854775807 |
float |
小数点6位 |
double |
小数点后16 |
验证代码:
fun main(agrs : Array<String>) { var B:Byte= Byte.MAX_VALUE; println("max:"+B); B= Byte.MIN_VALUE println("min:"+B); var nub:Int=Int.MAX_VALUE; println("Max:"+nub) nub=Int.MIN_VALUE println("Min:"+nub) var nub_short:Short=Short.MAX_VALUE; println("Max:"+nub_short) nub_short=Short.MIN_VALUE println("Min:"+nub_short) var nub_long:Long=Long.MAX_VALUE; println("Max:"+nub_long) nub_long=Long.MIN_VALUE println("Min:"+nub_long) var nub_double:Double=Double.MAX_VALUE println("Max:"+nub_double) nub_double=Double.MIN_VALUE; println("Min:"+nub_double) }