java.lang.Float.isInfinite()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(225)

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

Float.isInfinite介绍

[英]Indicates whether this object represents an infinite value.
[中]指示此对象是否表示无限值。

代码示例

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

/**
 * Checks whether the float value is infinite.
 *
 * @return true if infinite
 */
public boolean isInfinite() {
  return Float.isInfinite(value);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Checks whether the float value is infinite.
 * 
 * @return true if infinite
 */
public boolean isInfinite() {
  return Float.isInfinite(value);
}

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

/**
 * Checks whether the float value is infinite.
 */
public boolean isInfinite() {
  return Float.isInfinite(value);
}

代码示例来源:origin: apache/flink

@Override
  protected boolean isInfinite(Float number) {
    return number.isInfinite();
  }
}

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

/** True if the vector represents a pair of valid, non-infinite floating point numbers. */
public final boolean isValid() {
 return !Float.isNaN(x) && !Float.isInfinite(x) && !Float.isNaN(y) && !Float.isInfinite(y);
}

代码示例来源:origin: prestodb/presto

@Override
public boolean isNaN() {
  return Float.isNaN(_value) || Float.isInfinite(_value);
}

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

@Override
public boolean isNaN() {
  return Float.isNaN(_value) || Float.isInfinite(_value);
}

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

@Override
public String toSourceString(float value) {
  return Math.abs(value) <= Float.MAX_VALUE // Float.isFinite(value)
      ? Float.toString(value) + "f"
      : (Float.isInfinite(value) ? (value < 0.0f ? "-1.0f/0.0f" : "1.0f/0.0f") : "0.0f/0.0f");
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Returns the appropriate number of decimals to be used for the provided
 * number.
 *
 * @param number
 * @return
 */
public static int getDecimals(float number) {
  float i = roundToNextSignificant(number);
  if (Float.isInfinite(i))
    return 0;
  return (int) Math.ceil(-Math.log10(i)) + 2;
}

代码示例来源:origin: prestodb/presto

@Override
public boolean isNaN() {
  // can only occur for floating-point numbers
  if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) {
    Object value = _currentObject();
    if (value instanceof Double) {
      Double v = (Double) value;
      return v.isNaN() || v.isInfinite();
    }
    if (value instanceof Float) {
      Float v = (Float) value;
      return v.isNaN() || v.isInfinite();
    }
  }
  return false;
}

代码示例来源:origin: prestodb/presto

@Override
  protected Number getNormalizedValue()
  {
    if (value.isNaN() || value.isInfinite()) {
      return value;
    }
    return new BigDecimal(getValue().floatValue()).round(new MathContext(precision)).floatValue();
  }
}

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

@Override
public boolean isNaN() {
  // can only occur for floating-point numbers
  if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) {
    Object value = _currentObject();
    if (value instanceof Double) {
      Double v = (Double) value;
      return v.isNaN() || v.isInfinite();
    }
    if (value instanceof Float) {
      Float v = (Float) value;
      return v.isNaN() || v.isInfinite();
    }
  }
  return false;
}

代码示例来源:origin: prestodb/presto

@Description("round to given number of decimal places")
@ScalarFunction("round")
@SqlType(StandardTypes.REAL)
public static long roundFloat(@SqlType(StandardTypes.REAL) long num, @SqlType(StandardTypes.INTEGER) long decimals)
{
  float numInFloat = intBitsToFloat((int) num);
  if (Float.isNaN(numInFloat) || Float.isInfinite(numInFloat)) {
    return num;
  }
  double factor = Math.pow(10, decimals);
  if (numInFloat < 0) {
    return floatToRawIntBits((float) -(Math.round(-numInFloat * factor) / factor));
  }
  return floatToRawIntBits((float) (Math.round(numInFloat * factor) / factor));
}

代码示例来源:origin: prestodb/presto

@Override
public void writeNumber(float f) throws IOException
{
  if (_cfgNumbersAsStrings ||
    // [JACKSON-139]
      (isEnabled(Feature.QUOTE_NON_NUMERIC_NUMBERS) && ((Float.isNaN(f) || Float.isInfinite(f))))) {
    writeString(String.valueOf(f));
    return;
  }
  // What is the max length for floats?
  _verifyValueWrite(WRITE_NUMBER);
  writeRaw(String.valueOf(f));
}

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

@Override
public void writeNumber(float f) throws IOException
{
  if (_cfgNumbersAsStrings ||
    // [JACKSON-139]
      (isEnabled(Feature.QUOTE_NON_NUMERIC_NUMBERS) && ((Float.isNaN(f) || Float.isInfinite(f))))) {
    writeString(String.valueOf(f));
    return;
  }
  // What is the max length for floats?
  _verifyValueWrite(WRITE_NUMBER);
  writeRaw(String.valueOf(f));
}

代码示例来源:origin: prestodb/presto

@Override
public void writeNumber(float f) throws IOException
{
  if (_cfgNumbersAsStrings ||
    // [JACKSON-139]
    (((Float.isNaN(f) || Float.isInfinite(f))
      && Feature.QUOTE_NON_NUMERIC_NUMBERS.enabledIn(_features)))) {
    writeString(String.valueOf(f));
    return;
  }
  // What is the max length for floats?
  _verifyValueWrite(WRITE_NUMBER);
  writeRaw(String.valueOf(f));
}

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

@Override
public void writeNumber(float f) throws IOException
{
  if (_cfgNumbersAsStrings ||
    // [JACKSON-139]
    (((Float.isNaN(f) || Float.isInfinite(f))
      && Feature.QUOTE_NON_NUMERIC_NUMBERS.enabledIn(_features)))) {
    writeString(String.valueOf(f));
    return;
  }
  // What is the max length for floats?
  _verifyValueWrite(WRITE_NUMBER);
  writeRaw(String.valueOf(f));
}

代码示例来源:origin: google/guava

public void testIsFinite() {
 for (float value : NUMBERS) {
  assertEquals(!(Float.isInfinite(value) || Float.isNaN(value)), Floats.isFinite(value));
 }
}

代码示例来源:origin: chrisbanes/PhotoView

@Override
public boolean onScale(ScaleGestureDetector detector) {
  float scaleFactor = detector.getScaleFactor();
  if (Float.isNaN(scaleFactor) || Float.isInfinite(scaleFactor))
    return false;
   if (scaleFactor >= 0) {
    mListener.onScale(scaleFactor,
        detector.getFocusX(), detector.getFocusY());
  }
  return true;
}

代码示例来源:origin: square/moshi

@Override public Float fromJson(JsonReader reader) throws IOException {
 float value = (float) reader.nextDouble();
 // Double check for infinity after float conversion; many doubles > Float.MAX
 if (!reader.isLenient() && Float.isInfinite(value)) {
  throw new JsonDataException("JSON forbids NaN and infinities: " + value
    + " at path " + reader.getPath());
 }
 return value;
}

相关文章