java.math.BigInteger.not()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(321)

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

BigInteger.not介绍

[英]Returns a BigInteger whose value is ~this. The result of this operation is -this-1.

Implementation Note: Usage of this method is not recommended as the current implementation is not efficient.
[中]返回一个BigInteger,其值为~this。此操作的结果是-this-1。
实施说明:不建议使用此方法,因为当前的实施效率不高。

代码示例

代码示例来源:origin: io.netty/netty

private static BigInteger ipv6CidrMaskToMask(int cidrMask) {
  return BigInteger.ONE.shiftLeft(128 - cidrMask).subtract(BigInteger.ONE).not();
}

代码示例来源:origin: Graylog2/graylog2-server

private void calculate() throws UnknownHostException {
  final int targetSize;
  final BigInteger mask;
  if (inetAddress.getAddress().length == 4) {
    targetSize = 4;
    mask = (new BigInteger(1, MASK_IPV4)).not().shiftRight(prefixLength);
  } else {
    targetSize = 16;
    mask = (new BigInteger(1, MASK_IPV6)).not().shiftRight(prefixLength);
  }
  final BigInteger ipVal = new BigInteger(1, inetAddress.getAddress());
  final BigInteger startIp = ipVal.and(mask);
  final BigInteger endIp = startIp.add(mask.not());
  final byte[] startIpArr = toBytes(startIp.toByteArray(), targetSize);
  final byte[] endIpArr = toBytes(endIp.toByteArray(), targetSize);
  this.startAddress = InetAddress.getByAddress(startIpArr);
  this.endAddress = InetAddress.getByAddress(endIpArr);
}

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

private static long parseBinaryBigInteger(final byte[] buffer,
                     final int offset,
                     final int length,
                     final boolean negative) {
  final byte[] remainder = new byte[length - 1];
  System.arraycopy(buffer, offset + 1, remainder, 0, length - 1);
  BigInteger val = new BigInteger(remainder);
  if (negative) {
    // 2's complement
    val = val.add(BigInteger.valueOf(-1)).not();
  }
  if (val.bitLength() > 63) {
    throw new IllegalArgumentException("At offset " + offset + ", "
                      + length + " byte binary number"
                      + " exceeds maximum signed long"
                      + " value");
  }
  return negative ? -val.longValue() : val.longValue();
}

代码示例来源:origin: org.apache.ant/ant

private static long parseBinaryBigInteger(final byte[] buffer,
                     final int offset,
                     final int length,
                     final boolean negative) {
  final byte[] remainder = new byte[length - 1];
  System.arraycopy(buffer, offset + 1, remainder, 0, length - 1);
  BigInteger val = new BigInteger(remainder);
  if (negative) {
    // 2's complement
    val = val.add(BigInteger.valueOf(-1)).not();
  }
  if (val.bitLength() > 63) {
    throw new IllegalArgumentException(String.format(
        "At offset %d, %d byte binary number exceeds maximum signed long value",
        offset, length));
  }
  return negative ? -val.longValue() : val.longValue();
}

代码示例来源:origin: org.codehaus.groovy/groovy

protected Number bitwiseNegateImpl(Number left) {
  return toBigInteger(left).not();
}

代码示例来源:origin: org.codehaus.groovy/groovy

public static Object bitwiseNegate(Object value) {
  if (value instanceof Integer) {
    Integer number = (Integer) value;
    return ~number;
  }
  if (value instanceof Long) {
    Long number = (Long) value;
    return ~number;
  }
  if (value instanceof BigInteger) {
    return ((BigInteger) value).not();
  }
  if (value instanceof String) {
    // value is a regular expression.
    return StringGroovyMethods.bitwiseNegate((CharSequence)value.toString());
  }
  if (value instanceof GString) {
    // value is a regular expression.
    return StringGroovyMethods.bitwiseNegate((CharSequence)value.toString());
  }
  if (value instanceof ArrayList) {
    // value is a list.
    List newlist = new ArrayList();
    for (Object o : ((ArrayList) value)) {
      newlist.add(bitwiseNegate(o));
    }
    return newlist;
  }
  return invokeMethod(value, "bitwiseNegate", EMPTY_ARGS);
}

代码示例来源:origin: robovm/robovm

/** @see BigInteger#andNot(BigInteger) */
static BigInteger andNot(BigInteger val, BigInteger that) {
  if (that.sign == 0 ) {
    return val;
  }
  if (val.sign == 0) {
    return BigInteger.ZERO;
  }
  if (val.equals(BigInteger.MINUS_ONE)) {
    return that.not();
  }
  if (that.equals(BigInteger.MINUS_ONE)){
    return BigInteger.ZERO;
  }
  //if val == that, return 0
  if (val.sign > 0) {
    if (that.sign > 0) {
      return andNotPositive(val, that);
    } else {
      return andNotPositiveNegative(val, that);
        }
      } else {
    if (that.sign > 0) {
      return andNotNegativePositive(val, that);
    } else  {
      return andNotNegative(val, that);
    }
  }
}

代码示例来源:origin: robovm/robovm

return val.not();
return that.not();

代码示例来源:origin: hcoles/pitest

@Override
 BigInteger apply(BigInteger left, BigInteger right) {
  return left.not();
 }
}

代码示例来源:origin: org.jruby/jruby-core

/** rb_big_neg
 *
 */
@Override
public IRubyObject op_neg(ThreadContext context) {
  return RubyBignum.newBignum(context.runtime, value.not());
}

代码示例来源:origin: org.jruby/jruby-complete

/** rb_big_neg
 *
 */
@Override
public IRubyObject op_neg(ThreadContext context) {
  return RubyBignum.newBignum(context.runtime, value.not());
}

代码示例来源:origin: com.github.seancfoley/ipaddress

static boolean testRange(BigInteger lowerValue, BigInteger upperValue, BigInteger finalUpperValue, int bitCount, int divisionPrefixLen) {
  BigInteger networkMask = AddressDivisionGroupingBase.ALL_ONES.shiftLeft(bitCount - divisionPrefixLen);
  BigInteger hostMask = networkMask.not();
  return testRange(lowerValue, upperValue, finalUpperValue, networkMask, hostMask);
}

代码示例来源:origin: org.calrissian.mango/mango-core

@Override
public String encode(BigInteger value) {
  checkNotNull(value, "Null values are not allowed");
  return bigIntEncoder.encode(value.not());
}

代码示例来源:origin: org.calrissian.mango/mango-core

@Override
  public BigInteger decode(String value) throws TypeDecodingException {
    return bigIntEncoder.decode(value).not();
  }
}

代码示例来源:origin: net.sf.sf3jswing/kernel-core

/**
     *
     * @return
     */
    public Level not() {
    return new Level(n.not());
  }
}

代码示例来源:origin: org.netbeans.api/org-jruby

/** rb_big_neg     
 * 
 */
@JRubyMethod(name = "~")
public IRubyObject op_neg() {
  return RubyBignum.newBignum(getRuntime(), value.not());
}

代码示例来源:origin: ognl/ognl

public static Object bitNegate(Object value)
{
  int type = getNumericType(value);
  switch(type) {
  case BIGDEC:
  case BIGINT:
    return bigIntValue(value).not();
  default:
    return newInteger(type, ~longValue(value));
  }
}

代码示例来源:origin: opensymphony/ognl

public static Object bitNegate( Object value )
  {
    int type = getNumericType(value);
    switch ( type )
     {
      case BIGDEC:
      case BIGINT:    return bigIntValue(value).not();
      default:        return newInteger( type, ~longValue(value) );
     }
  }
}

代码示例来源:origin: jkuhnert/ognl

public static Object bitNegate(Object value)
{
  int type = getNumericType(value);
  switch(type) {
  case BIGDEC:
  case BIGINT:
    return bigIntValue(value).not();
  default:
    return newInteger(type, ~longValue(value));
  }
}

代码示例来源:origin: org.apache.ibatis/ibatis-core

public static Object bitNegate(Object value) {
  int type = getNumericType(value);
  switch (type) {
   case BIGDEC:
   case BIGINT:
    return bigIntValue(value).not();
   default:
    return newInteger(type, ~longValue(value));
  }
 }
}

相关文章