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

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

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

BigInteger.byteValueExact介绍

暂无

代码示例

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-queryalgebra-evaluation

@Override
protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue)
  throws ArithmeticException
{
  return Optional.of(vf.createLiteral(integerValue.byteValueExact()));
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

@Override
protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue)
  throws ArithmeticException
{
  return Optional.of(vf.createLiteral(integerValue.byteValueExact()));
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

@Override
protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue)
  throws ArithmeticException
{
  if (integerValue.compareTo(BigInteger.ZERO) >= 0) {
    return Optional.of(vf.createLiteral(String.valueOf(integerValue.byteValueExact()), getXsdDatatype()));
  }
  return Optional.empty();
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-queryalgebra-evaluation

@Override
protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue)
  throws ArithmeticException
{
  if (integerValue.compareTo(BigInteger.ZERO) >= 0) {
    return Optional.of(vf.createLiteral(String.valueOf(integerValue.byteValueExact()), getXsdDatatype()));
  }
  return Optional.empty();
}

代码示例来源:origin: io.atlasmap/atlas-core

@AtlasConversionInfo(sourceType = FieldType.DECIMAL, targetType = FieldType.BYTE,
    concerns = {AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART})
public Byte toByte(BigDecimal value) throws AtlasConversionException {
  if (value == null) {
    return null;
  }
  try {
    return value.toBigInteger().byteValueExact();
  } catch (ArithmeticException e) {
    throw new AtlasConversionException(String.format(
        "BigDecimal %s is greater than Byte.MAX_VALUE or less than Byte.MIN_VALUE", value));
  }
}

代码示例来源:origin: io.atlasmap/atlas-core

@AtlasConversionInfo(sourceType = FieldType.BIG_INTEGER, targetType = FieldType.BYTE,
    concerns = AtlasConversionConcern.RANGE)
public Byte toByte(BigInteger value) throws AtlasConversionException {
  if (value == null) {
    return null;
  }
  try {
    return value.byteValueExact();
  } catch (ArithmeticException e) {
    throw new AtlasConversionException(String.format(
        "BigInteger %s is greater than Byte.MAX_VALUE or less than Byte.MIN_VALUE", value));
  }
}

代码示例来源:origin: net.lecousin/core

return Byte.valueOf(value.byteValueExact());
if (short.class.equals(type) || Short.class.equals(type))
  return Short.valueOf(value.shortValueExact());

代码示例来源:origin: org.kopitubruk.util/JSONUtil

return Byte.valueOf(bigInt.byteValueExact());
}catch ( ArithmeticException e ){

代码示例来源:origin: kframework/k

/**
 * Recovers the ECDSA Public key from a message hash and signature
 * @param messageHash a 32-character string in Latin-1 encoding representing the 32-byte message hash of the signed message
 * @param v The recovery id, in the range 27-34, to use to recover the correct public key
 * @param r The r component of the message signature, as a 32-character Latin-1 string
 * @param s The s component of the message signature, as a 32-character Latin-1 string
 * @return Output String (64 characters) in Latin-1 encoding representing the public key recovered upon success. Returns
 *         the empty string if key recovery fails due to invalid input.
 * */
public static StringToken ecdsaRecover(StringToken messageHash, IntToken v, StringToken r, StringToken s, TermContext context) {
  byte[] hashBytes = StringUtils.getBytesIso8859_1(messageHash.stringValue());
  byte vByte = v.bigIntegerValue().byteValueExact();
  byte[] rBytes = StringUtils.getBytesIso8859_1(r.stringValue());
  byte[] sBytes = StringUtils.getBytesIso8859_1(s.stringValue());
  try {
    ECDSARecover key = ECDSARecover.signatureToKey(hashBytes, rBytes, sBytes, vByte);
    return StringToken.of(Arrays.copyOfRange(key.getPubKey(), 1, 65));
  } catch (SignatureException | IllegalArgumentException e) {
    return StringToken.of("");
  }
}

相关文章

微信公众号

最新文章

更多