gpt4 book ai didi

java - Java int 总是 32 位吗?

转载 作者:IT老高 更新时间:2023-10-28 11:48:16 25 4
gpt4 key购买 nike

Java 的 int 是否始终是 32 位有符号整数?

最佳答案

是的,它在 The Java Language Specification 中定义.

来自 Section 4.2: Primitive Types and Values :

The integral types are byte, short, int, and long, whose values are 8-bit, 16-bit, 32-bit and 64-bit signed two's-complement integers, respectively, and char, whose values are 16-bit unsigned integers representing UTF-16 code units (§3.1).

另外来自 Section 4.2.1: Integral Types and Values :

The values of the integral types are integers in the following ranges:

  • 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 - Java int 总是 32 位吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1032982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com