org.apache.commons.compress.archivers.zip.ZipUtil.adjustToLong()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.apache.commons.compress.archivers.zip.ZipUtil.adjustToLong()方法的一些代码示例,展示了ZipUtil.adjustToLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.adjustToLong()方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipUtil
类名称:ZipUtil
方法名:adjustToLong

ZipUtil.adjustToLong介绍

[英]Assumes a negative integer really is a positive integer that has wrapped around and re-creates the original value.
[中]假设一个负整数真的是一个正整数,它环绕并重新创建了原始值。

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * <p>
 * Converts a long into a BigInteger.  Negative numbers between -1 and
 * -2^31 are treated as unsigned 32 bit (e.g., positive) integers.
 * Negative numbers below -2^31 cause an IllegalArgumentException
 * to be thrown.
 * </p>
 *
 * @param l long to convert to BigInteger.
 * @return BigInteger representation of the provided long.
 */
static BigInteger longToBig(long l) {
  if (l < Integer.MIN_VALUE) {
    throw new IllegalArgumentException("Negative longs < -2^31 not permitted: [" + l + "]");
  } else if (l < 0 && l >= Integer.MIN_VALUE) {
    // If someone passes in a -2, they probably mean 4294967294
    // (For example, Unix UID/GID's are 32 bit unsigned.)
    l = ZipUtil.adjustToLong((int) l);
  }
  return BigInteger.valueOf(l);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * <p>
 * Converts a long into a BigInteger.  Negative numbers between -1 and
 * -2^31 are treated as unsigned 32 bit (e.g., positive) integers.
 * Negative numbers below -2^31 cause an IllegalArgumentException
 * to be thrown.
 * </p>
 *
 * @param l long to convert to BigInteger.
 * @return BigInteger representation of the provided long.
 */
static BigInteger longToBig(long l) {
  if (l < Integer.MIN_VALUE) {
    throw new IllegalArgumentException("Negative longs < -2^31 not permitted: [" + l + "]");
  } else if (l < 0 && l >= Integer.MIN_VALUE) {
    // If someone passes in a -2, they probably mean 4294967294
    // (For example, Unix UID/GID's are 32 bit unsigned.)
    l = ZipUtil.adjustToLong((int) l);
  }
  return BigInteger.valueOf(l);
}

相关文章