0
点赞
收藏
分享

微信扫一扫

java中无符号类型的第三方库jOOU

 

java中整数默认都是有符号类型的,在进行第三方库或者c/c++调用时有时候需要无符号类型。

比如海康威视SDK调用

常见的无符号类型 unsigned int, unsigned char, unsigned short, unsigned byte, unsigned long.

以下介绍一个三方库​​jOOU​​, github地址 https://github.com/jOOQ/jOOU,他能支持 unsigned byte/short/int/long不过不支持char。

java是unicode字符集,utf-8编码,char默认应是双字节的。

官方介绍:

jOOU - Unsigned Integers jOOU provides unsigned integer versions for the four Java integer types byte, short, int and long.

用法:(java6-8)

<dependency>
<groupId>org.jooq</groupId>
<artifactId>joou-java-6</artifactId>
<version>0.9.4</version>
</dependency>

 

there is a utility class called ​​org.joou.Unsigned​​ with factory methods allowing for creating unsigned wrappers like this:

import static org.joou.Unsigned.*;

// and then...
UByte b = ubyte(1);
UShort s = ushort(1);
UInteger i = uint(1);
ULong l = ulong(1);

 

 

其他支持无符号类型的库Guava

Generic utilities

These methods' signed analogues are provided in the wrapper classes in the JDK.

UnsignedLongs, UnsignedLong, UnsignedBytes, UnsignedInteger, UnsignedInts,

举报

相关推荐

0 条评论