左到右范围从小到大:byte->short->int->long->float->double
各自所占字节大小:1字节、2字节、4字节、8字节、4字节、8字节
各自所占位数大小(1字节8位):8位、16位、32位、64位、32位、64位
各自所表示范围:
byte:-2^7(-128)~2^7-1(127)
short:-2^15(-32768)~2^15-1(32767)
int:-2^31(-2147483648)~2^31-1(2147483647)
long: 2^63~2^63-1、
float:-3.4E38(-3.4*10^38)~3.4E38(3.4*10^38)
double:-1.7E308(-1.7*10^308)~1.7E308(1.7*10^308)
long为长整型,平分正负,float为浮点数,内存表示与整数不同,所以虽然long占用字节比float大,但是范围比float小。
浮点数具体计算我也记不清,感兴趣的可以看看:
https://zhidao.baidu.com/question/10538690.html和https://www.jianshu.com/p/9360a35bca7c