本文整理了Java中java.math.BigInteger.doubleValue()
方法的一些代码示例,展示了BigInteger.doubleValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigInteger.doubleValue()
方法的具体详情如下:
包路径:java.math.BigInteger
类名称:BigInteger
方法名:doubleValue
[英]Returns this BigInteger as a double. If this is too big to be represented as a double, then Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY is returned. Note that not all integers in the range [-Double.MAX_VALUE, Double.MAX_VALUE] can be exactly represented as a double.
[中]以双精度形式返回此BigInteger。如果这个值太大,无法表示为double,则为double。正无穷大或双精度。返回负无穷大。请注意,[-Double.MAX\u VALUE,Double.MAX\u VALUE]范围内的所有整数都不能精确表示为Double。
代码示例来源:origin: prestodb/presto
@Override
public double doubleValue() { return _value.doubleValue(); }
代码示例来源:origin: redisson/redisson
@Override
public double doubleValue() { return _value.doubleValue(); }
代码示例来源:origin: robovm/robovm
/**
* Returns this {@code BigInteger} as a float. If {@code this} is too big to
* be represented as a float, then {@code Float.POSITIVE_INFINITY} or
* {@code Float.NEGATIVE_INFINITY} is returned. Note that not all integers
* in the range {@code [-Float.MAX_VALUE, Float.MAX_VALUE]} can be exactly
* represented as a float.
*/
@Override
public float floatValue() {
return (float) doubleValue();
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
@Override
public double getDoubleValue() { return _value.doubleValue(); }
代码示例来源:origin: prestodb/presto
@Override
public double getRingFraction(String start, String end)
{
return getTokenCountInRange(start, end).doubleValue() / TOTAL_TOKEN_COUNT.doubleValue();
}
代码示例来源:origin: prestodb/presto
@Override
public double getRingFraction(String start, String end)
{
return getTokenCountInRange(start, end).doubleValue() / TOTAL_TOKEN_COUNT.doubleValue();
}
代码示例来源:origin: apache/drill
@Override
public double doubleValue() { return _value.doubleValue(); }
代码示例来源:origin: prestodb/presto
protected void convertNumberToDouble() throws IOException
{
/* 05-Aug-2008, tatus: Important note: this MUST start with
* more accurate representations, since we don't know which
* value is the original one (others get generated when
* requested)
*/
if ((_numTypesValid & NR_BIGDECIMAL) != 0) {
_numberDouble = _numberBigDecimal.doubleValue();
} else if ((_numTypesValid & NR_BIGINT) != 0) {
_numberDouble = _numberBigInt.doubleValue();
} else if ((_numTypesValid & NR_LONG) != 0) {
_numberDouble = (double) _numberLong;
} else if ((_numTypesValid & NR_INT) != 0) {
_numberDouble = (double) _numberInt;
} else {
_throwInternal();
}
_numTypesValid |= NR_DOUBLE;
}
代码示例来源:origin: redisson/redisson
protected void convertNumberToDouble() throws IOException
{
/* 05-Aug-2008, tatus: Important note: this MUST start with
* more accurate representations, since we don't know which
* value is the original one (others get generated when
* requested)
*/
if ((_numTypesValid & NR_BIGDECIMAL) != 0) {
_numberDouble = _numberBigDecimal.doubleValue();
} else if ((_numTypesValid & NR_BIGINT) != 0) {
_numberDouble = _numberBigInt.doubleValue();
} else if ((_numTypesValid & NR_LONG) != 0) {
_numberDouble = (double) _numberLong;
} else if ((_numTypesValid & NR_INT) != 0) {
_numberDouble = (double) _numberInt;
} else {
_throwInternal();
}
_numTypesValid |= NR_DOUBLE;
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Power of a BigInteger to a BigInteger certain exponent. Called by the '**' operator.
*
* @param self a BigInteger
* @param exponent a BigInteger exponent
* @return a BigInteger to the power of a the exponent
* @since 2.3.8
*/
public static BigInteger power(BigInteger self, BigInteger exponent) {
if ((exponent.signum() >= 0) && (exponent.compareTo(BI_INT_MAX) <= 0)) {
return self.pow(exponent.intValue());
} else {
return BigDecimal.valueOf(Math.pow(self.doubleValue(), exponent.doubleValue())).toBigInteger();
}
}
代码示例来源:origin: stackoverflow.com
private static final double LOG2 = Math.log(2.0);
/**
* Computes the natural logarithm of a BigInteger. Works for really big
* integers (practically unlimited)
*
* @param val Argument, positive integer
* @return Natural logarithm, as in <tt>Math.log()</tt>
*/
public static double logBigInteger(BigInteger val) {
int blex = val.bitLength() - 1022; // any value in 60..1023 is ok
if (blex > 0)
val = val.shiftRight(blex);
double res = Math.log(val.doubleValue());
return blex > 0 ? res + blex * LOG2 : res;
}
代码示例来源:origin: org.apache.commons/commons-math3
/**
* <p>
* Returns a <code>double</code> whose value is
* <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form.
* </p>
*
* @param exponent
* exponent to which this <code>BigFraction</code> is to be raised.
* @return <tt>this<sup>exponent</sup></tt>.
*/
public double pow(final double exponent) {
return FastMath.pow(numerator.doubleValue(), exponent) /
FastMath.pow(denominator.doubleValue(), exponent);
}
代码示例来源:origin: org.codehaus.jackson/jackson-core-asl
protected void convertNumberToDouble()
throws IOException, JsonParseException
{
/* 05-Aug-2008, tatus: Important note: this MUST start with
* more accurate representations, since we don't know which
* value is the original one (others get generated when
* requested)
*/
if ((_numTypesValid & NR_BIGDECIMAL) != 0) {
_numberDouble = _numberBigDecimal.doubleValue();
} else if ((_numTypesValid & NR_BIGINT) != 0) {
_numberDouble = _numberBigInt.doubleValue();
} else if ((_numTypesValid & NR_LONG) != 0) {
_numberDouble = (double) _numberLong;
} else if ((_numTypesValid & NR_INT) != 0) {
_numberDouble = (double) _numberInt;
} else {
_throwInternal(); // should never get here
}
_numTypesValid |= NR_DOUBLE;
}
代码示例来源:origin: hibernate/hibernate-orm
private double extractDoubleValue(Object value) {
if ( value instanceof BigInteger ) {
return ( ( BigInteger ) value ).doubleValue();
}
else if ( value instanceof BigDecimal ) {
return ( ( BigDecimal ) value ).doubleValue();
}
else {
return Double.valueOf( value.toString() ).doubleValue();
}
}
代码示例来源:origin: graphql-java/graphql-java
@Override
public Double parseLiteral(Object input) {
if (input instanceof IntValue) {
return ((IntValue) input).getValue().doubleValue();
} else if (input instanceof FloatValue) {
return ((FloatValue) input).getValue().doubleValue();
} else {
throw new CoercingParseLiteralException(
"Expected AST type 'IntValue' or 'FloatValue' but was '" + typeName(input) + "'."
);
}
}
});
代码示例来源:origin: google/guava
@AndroidIncompatible // TODO(cpovirk): File bug for BigDecimal.doubleValue().
public void testBigToDouble() {
for (BigInteger b : ALL_BIGINTEGER_CANDIDATES) {
if (b.doubleValue() != DoubleUtils.bigToDouble(b)) {
failFormat(
"Converting %s to double: expected doubleValue %s but got bigToDouble %s",
b, b.doubleValue(), DoubleUtils.bigToDouble(b));
}
}
}
代码示例来源:origin: google/guava
public void testConstantsEverySixteenthFactorial() {
for (int i = 0, n = 0; n <= DoubleMath.MAX_FACTORIAL; i++, n += 16) {
assertEquals(
BigIntegerMath.factorial(n).doubleValue(), DoubleMath.everySixteenthFactorial[i]);
}
}
代码示例来源:origin: google/guava
public void testDoubleValue() {
for (long value : TEST_LONGS) {
UnsignedLong unsignedValue = UnsignedLong.fromLongBits(value);
assertEquals(unsignedValue.bigIntegerValue().doubleValue(), unsignedValue.doubleValue());
}
}
代码示例来源:origin: google/guava
public void testDoubleValue() {
for (int value : TEST_INTS) {
UnsignedInteger unsignedValue = UnsignedInteger.fromIntBits(value);
assertEquals(unsignedValue.bigIntegerValue().doubleValue(), unsignedValue.doubleValue());
}
}
代码示例来源:origin: google/guava
@GwtIncompatible // Math.ulp
public void testFactorial() {
for (int i = 0; i <= DoubleMath.MAX_FACTORIAL; i++) {
double actual = BigIntegerMath.factorial(i).doubleValue();
double result = DoubleMath.factorial(i);
assertEquals(actual, result, Math.ulp(actual));
}
}
内容来源于网络,如有侵权,请联系作者删除!