java Byte源码分析

源码:

1 public static int toUnsignedInt(byte x) {
2         return ((int) x) & 0xff;
3     }

原理:

-128(byte)
原码:10000000
反码:11111111
补码:10000000

-128(byte)转换为int类型:
10000000 -> 11111111 11111111 11111111 10000000
-128(int)& 0xff :
11111111 11111111 11111111 10000000 & 11111111 = 00000000 00000000 00000000 10000000

相关文章:

  • 2021-09-13
  • 2021-10-13
  • 2021-05-21
  • 2021-10-18
  • 2021-06-16
  • 2021-12-20
  • 2021-12-09
  • 2022-02-01
猜你喜欢
  • 2022-01-15
  • 2022-12-23
  • 2021-12-31
  • 2021-05-17
  • 2021-07-26
  • 2021-08-11
  • 2022-01-31
相关资源
相似解决方案