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

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

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

Float.isNaN介绍

[英]Indicates whether this object is a Not-a-Number (NaN) value.
[中]指示此对象是否为*非数字(NaN)*值。

代码示例

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

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

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

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

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

/**
 * Checks whether the value is the special NaN value.
 */
public boolean isNaN() {
  return Float.isNaN(value);
}

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

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

代码示例来源:origin: stanfordnlp/CoreNLP

public static boolean hasNaN(float[] a) {
 for (float x : a) {
  if (Float.isNaN(x)) return true;
 }
 return false;
}

代码示例来源: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: prestodb/presto

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

代码示例来源: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: 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: google/guava

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

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

@Test
  public void testNanHash()
  {
    int[] nanRepresentations = {floatToIntBits(Float.NaN), 0xffc00000, 0x7fc00000, 0x7fc01234, 0xffc01234};
    for (int nanRepresentation : nanRepresentations) {
      assertTrue(isNaN(intBitsToFloat(nanRepresentation)));
      assertEquals(RealOperators.hashCode(nanRepresentation), RealOperators.hashCode(nanRepresentations[0]));
    }
  }
}

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

public boolean touchDown (int screenX, int screenY, int pointer, int button) {
  if (!Float.isNaN(time)) // if "walking" was interrupted by this touch down event
    startPosition.set(getPosition(time)); // set startPosition to the current position
  targetPosition.set(stage.screenToStageCoordinates(targetPosition.set(screenX, screenY)));
  time = 0;
  return true;
}

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

@Override
protected void calcMinMax(BarEntry e) {
  if (e != null && !Float.isNaN(e.getY())) {
    if (e.getYVals() == null) {
      if (e.getY() < mYMin)
        mYMin = e.getY();
      if (e.getY() > mYMax)
        mYMax = e.getY();
    } else {
      if (-e.getNegativeSum() < mYMin)
        mYMin = -e.getNegativeSum();
      if (e.getPositiveSum() > mYMax)
        mYMax = e.getPositiveSum();
    }
    calcMinMaxX(e);
  }
}

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

public void testMax() {
 assertEquals(GREATEST, Floats.max(GREATEST));
 assertEquals(LEAST, Floats.max(LEAST));
 assertEquals(
   (float) 9,
   Floats.max((float) 8, (float) 6, (float) 7, (float) 5, (float) 3, (float) 0, (float) 9));
 assertEquals(0f, Floats.max(-0f, 0f));
 assertEquals(0f, Floats.max(0f, -0f));
 assertEquals(GREATEST, Floats.max(NUMBERS));
 assertTrue(Float.isNaN(Floats.max(VALUES)));
}

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

public void testMin() {
 assertEquals(LEAST, Floats.min(LEAST));
 assertEquals(GREATEST, Floats.min(GREATEST));
 assertEquals(
   (float) 0,
   Floats.min((float) 8, (float) 6, (float) 7, (float) 5, (float) 3, (float) 0, (float) 9));
 assertEquals(-0f, Floats.min(-0f, 0f));
 assertEquals(-0f, Floats.min(0f, -0f));
 assertEquals(LEAST, Floats.min(NUMBERS));
 assertTrue(Float.isNaN(Floats.min(VALUES)));
}

相关文章