【发布时间】:2014-02-01 02:17:42
【问题描述】:
我对 Java 支持哪些无符号数据类型有点困惑?
我读过Why doesn't Java support unsigned ints?,但我不明白它非常复杂的解释(至少对我来说)。
【问题讨论】:
-
它让事情变得简单。
-
@zapl try
char ch = '0'; ch *= 1.1; System.out.println(ch);给你4 -
@zapl 引用authoritative source:
The numeric types are the integral types and the floating-point types. 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. -
@zapl 是的,与
byte和short相同,但本质上它是一个16 位的值,实际上是一个数字。