Understanding Java bytes

后端 未结 6 902
抹茶落季
抹茶落季 2020-12-31 18:48

So at work yesterday, I had to write an application to count the pages in an AFP file. So I dusted off my MO:DCA spec PDF and found the structured field BPG (Begin Pag

6条回答
  •  庸人自扰
    2020-12-31 19:04

    To get the unsigned byte value you can either.

    int u = b & 0xFF;
    

    or

    int u = b < 0 ? b + 256 : b;
    

提交回复
热议问题