Java int总是32位吗? [英] Is a Java int always 32 bits?
本文介绍了Java int总是32位吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java的 int
总是和任何地方都是32位有符号整数吗?
Will Java's int
always and everywhere be a 32 bit signed integer?
推荐答案
是的,它是在 Java语言规范。
来自第4.2节:原始类型和值:
整数类型是
byte
,short
,
int
和long
,其值为8位,
16位,32位和64位签名
二进制补码整数,
,和char
,其值
是16位无符号整数
代表UTF-16代码单位(§3.1)。
The integral types are
byte
,short
,int
, andlong
, whose values are 8-bit, 16-bit, 32-bit and 64-bit signed two's-complement integers, respectively, andchar
, whose values are 16-bit unsigned integers representing UTF-16 code units (§3.1).
另外来自 Secti 4.2.1:积分类型和值:
积分类型的值是
整数以下范围:
The values of the integral types are integers in the following ranges:
- 对于字节,从-128到127,包括
- 简而言之,来自-32768到32767,包括
- 对于int,从-2147483648到2147483647,包括
- 长,从-9223372036854775808到9223372036854775807,包括
- 对于char,从'\ u0000'到'\\\ fffff'包括在内,即从0到65535
- For byte, from -128 to 127, inclusive
- For short, from -32768 to 32767, inclusive
- For int, from -2147483648 to 2147483647, inclusive
- For long, from -9223372036854775808 to 9223372036854775807, inclusive
- For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535
这篇关于Java int总是32位吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文