What is the best way to work around the fact that ALL Java bytes are signed?

后端 未结 7 1154
误落风尘
误落风尘 2020-12-02 12:29

In Java, there is no such thing as an unsigned byte.

Working with some low level code, occasionally you need to work with bytes that have unsigned values greater tha

相关标签:
7条回答
  • 2020-12-02 12:55

    Probably your best bet is to use an integer rather than a byte. It has the room to allow for numbers greater than 128 without the overhead of having to create a special object to replace byte.

    This is also suggested by people smarter than me (everybody)

    • http://www.darksleep.com/player/JavaAndUnsignedTypes.html
    • http://www.jguru.com/faq/view.jsp?EID=13647
    0 讨论(0)
提交回复
热议问题