zoukankan      html  css  js  c++  java
  • 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,

  • 相关阅读:
    Python为什么要self
    安全散列算法(secure hash algorithm,SHA)
    傅里叶变换

    K 最近邻(k-nearest neighbours,KNN)算法
    贪婪算法
    狄克斯特拉算法
    广度优先搜索
    快速排序
    选择排序
  • 原文地址:https://www.cnblogs.com/passedbylove/p/13284187.html
Copyright © 2011-2022 走看看