本文整理了Java中java.lang.Double.isInfinite()
方法的一些代码示例,展示了Double.isInfinite()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.isInfinite()
方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:isInfinite
[英]Indicates whether this object represents an infinite value.
[中]
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Checks whether the double value is infinite.
*
* @return true if infinite
*/
public boolean isInfinite() {
return Double.isInfinite(value);
}
代码示例来源:origin: redisson/redisson
/**
* Checks whether the double value is infinite.
*/
public boolean isInfinite() {
return Double.isInfinite(value);
}
代码示例来源:origin: prestodb/presto
@Override
public boolean isNaN() {
if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) {
if ((_numTypesValid & NR_DOUBLE) != 0) {
// 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8
double d = _numberDouble;
return Double.isNaN(d) || Double.isInfinite(d);
}
}
return false;
}
代码示例来源:origin: prestodb/presto
public boolean isSingleValue()
{
return distinctValuesCount == 1.0
&& Double.compare(lowValue, highValue) == 0
&& !isInfinite(lowValue);
}
代码示例来源:origin: redisson/redisson
@Override
public boolean isNaN() {
if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) {
if ((_numTypesValid & NR_DOUBLE) != 0) {
// 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8
double d = _numberDouble;
return Double.isNaN(d) || Double.isInfinite(d);
}
}
return false;
}
代码示例来源:origin: redisson/redisson
@Override
public String toSourceString(double value) {
return Math.abs(value) <= Double.MAX_VALUE // Double.isFinite(value)
? Double.toString(value)
: (Double.isInfinite(value) ? (value < 0.0d ? "-1.0/0.0" : "1.0/0.0") : "0.0/0.0");
}
代码示例来源:origin: skylot/jadx
private static String doubleToString(double value) {
if (Double.compare(value, Math.floor(value)) == 0
&& !Double.isInfinite(value)) {
return Integer.toString((int) value);
}
// remove trailing zeroes
NumberFormat f = NumberFormat.getInstance(Locale.ROOT);
f.setMaximumFractionDigits(4);
f.setMinimumIntegerDigits(1);
return f.format(value);
}
代码示例来源:origin: redisson/redisson
private String value(double score, boolean inclusive) {
StringBuilder element = new StringBuilder();
if (!inclusive) {
element.append("(");
}
if (Double.isInfinite(score)) {
element.append(score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf(score).toPlainString());
}
return element.toString();
}
代码示例来源:origin: prestodb/presto
private static void checkLongitude(double longitude)
{
if (Double.isNaN(longitude) || Double.isInfinite(longitude) || longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Longitude must be between -180 and 180");
}
}
代码示例来源:origin: prestodb/presto
public static Estimate of(double value)
{
if (isNaN(value)) {
throw new IllegalArgumentException("value is NaN");
}
if (isInfinite(value)) {
throw new IllegalArgumentException("value is infinite");
}
return new Estimate(value);
}
代码示例来源:origin: prestodb/presto
public static Estimate of(double value)
{
if (isNaN(value)) {
throw new IllegalArgumentException("value is NaN");
}
if (isInfinite(value)) {
throw new IllegalArgumentException("value is infinite");
}
return new Estimate(value);
}
代码示例来源:origin: prestodb/presto
private static void checkLatitude(double latitude)
{
if (Double.isNaN(latitude) || Double.isInfinite(latitude) || latitude < MIN_LATITUDE || latitude > MAX_LATITUDE) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Latitude must be between -90 and 90");
}
}
代码示例来源:origin: prestodb/presto
@Override
protected Number getNormalizedValue()
{
if (value.isNaN() || value.isInfinite()) {
return value;
}
return new BigDecimal(getValue().doubleValue()).round(new MathContext(precision)).doubleValue();
}
}
代码示例来源:origin: prestodb/presto
public DataSize(double size, Unit unit)
{
checkArgument(!Double.isInfinite(size), "size is infinite");
checkArgument(!Double.isNaN(size), "size is not a number");
checkArgument(size >= 0, "size is negative");
requireNonNull(unit, "unit is null");
this.value = size;
this.unit = unit;
}
代码示例来源:origin: prestodb/presto
public Duration(double value, TimeUnit unit)
{
checkArgument(!Double.isInfinite(value), "value is infinite");
checkArgument(!Double.isNaN(value), "value is not a number");
checkArgument(value >= 0, "value is negative");
requireNonNull(unit, "unit is null");
this.value = value;
this.unit = unit;
}
代码示例来源:origin: prestodb/presto
@Override
public OptionalDouble getValueFromPlanNodeEstimate(PlanNodeStatsEstimate planNodeStatsEstimate, StatsContext statsContext)
{
double lowValue = getSymbolStatistics(planNodeStatsEstimate, columnName, statsContext).getLowValue();
if (isInfinite(lowValue)) {
return OptionalDouble.empty();
}
return OptionalDouble.of(lowValue);
}
代码示例来源:origin: prestodb/presto
@Override
public OptionalDouble getValueFromPlanNodeEstimate(PlanNodeStatsEstimate planNodeStatsEstimate, StatsContext statsContext)
{
double highValue = getSymbolStatistics(planNodeStatsEstimate, columnName, statsContext).getHighValue();
if (isInfinite(highValue)) {
return OptionalDouble.empty();
}
return OptionalDouble.of(highValue);
}
代码示例来源:origin: google/guava
public void testIsFinite() {
for (double value : NUMBERS) {
assertEquals(!(Double.isNaN(value) || Double.isInfinite(value)), Doubles.isFinite(value));
}
}
代码示例来源:origin: prestodb/presto
@Description("test if value is infinite")
@ScalarFunction
@SqlType(StandardTypes.BOOLEAN)
public static boolean isInfinite(@SqlType(StandardTypes.DOUBLE) double num)
{
return Double.isInfinite(num);
}
代码示例来源:origin: google/guava
@GwtIncompatible // DoubleMath.isPowerOfTwo, DoubleMath.log2(double, RoundingMode), StrictMath
public void testIsPowerOfTwo() {
for (double x : ALL_DOUBLE_CANDIDATES) {
boolean expected =
x > 0
&& !Double.isInfinite(x)
&& !Double.isNaN(x)
&& StrictMath.pow(2.0, DoubleMath.log2(x, FLOOR)) == x;
assertEquals(expected, DoubleMath.isPowerOfTwo(x));
}
}
内容来源于网络,如有侵权,请联系作者删除!