java中的字节范围是-128到127.How有可能吗? [英] How the byte range is -128 to 127 in java.How it is possible?
本文介绍了java中的字节范围是-128到127.How有可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1字节= 8位
我将 1111 1111
二进制数转换为十进制。它给了我 255
。
I converted 1111 1111
binary number to decimal .it is giving me 255
.
但当我将 0111 1111
binaru编号转换为十进制.it给我 127
。
But when i converted 0111 1111
binaru number to decimal .it is giving me 127
.
所以在什么基础上声明范围。请帮助我。
So on what basis the range is declared.Please help me.
提前致谢...
推荐答案
Java中的数字类型签字,意味着他们可能是消极或积极的。最左边的位(最重要的位)用于表示符号,其中 1
表示否定, 0
表示正数。
The number types in Java are signed, meaning they can be negative or positive. The leftmost bit (the most significant bit) is used to represent the sign, where a 1
means negative and 0
means positive.
字节
Max 01111111 = +127
Min 10000000 = -128
11111111 = -1
短
Max 0111111111111111 = +32767
Min 1000000000000000 = -32768
0000000011111111 = +255
二进制负数用 2的补充形式。
这篇关于java中的字节范围是-128到127.How有可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文