java byte data type

后端 未结 3 914
后悔当初
后悔当初 2021-01-13 00:31

In Sun\' tutorial it says about a byte:

byte: The byte data type is an 8-bit signed two\'s complement integer. It has a minimum value of -128 and a ma

3条回答
  •  被撕碎了的回忆
    2021-01-13 01:18

    Bytes save memory due to being only one byte long, whereas most other data types commonly used are 4 or 8 bytes long.

    Twos complement is the almost universal way to encode signed numbers as binary. This encoding has the nice property that incrementing any value as if it were just binary, gives you the next integer value, even as the value passes through zero. The same CPU circuitry can compute signed or unsigned integers.

提交回复
热议问题