congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Math.nextDown
Code IndexAdd Tabnine to your IDE (free)

How to use
nextDown
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.nextDown (Showing top 20 results out of 315)

origin: org.apache.lucene/lucene-core

/**
 * Return the greatest float that compares less than {@code f} consistently
 * with {@link Float#compare}. The only difference with
 * {@link Math#nextDown(float)} is that this method returns {@code -0f} when
 * the argument is {@code +0f}.
 */
public static float nextDown(float f) {
 if (Float.floatToIntBits(f) == 0) { // +0f
  return -0f;
 }
 return Math.nextDown(f);
}
origin: org.apache.lucene/lucene-core

/**
 * Return the greatest double that compares less than {@code d} consistently
 * with {@link Double#compare}. The only difference with
 * {@link Math#nextDown(double)} is that this method returns {@code -0d} when
 * the argument is {@code +0d}.
 */
public static double nextDown(double d) {
 if (Double.doubleToLongBits(d) == 0L) { // +0d
  return -0f;
 }
 return Math.nextDown(d);
}
origin: google/error-prone

@Override
Float nextNumber(Number actual) {
 float number = actual.floatValue();
 return Math.min(Math.nextUp(number) - number, number - Math.nextDown(number));
}
origin: google/error-prone

@Override
Double nextNumber(Number actual) {
 double number = actual.doubleValue();
 return Math.min(Math.nextUp(number) - number, number - Math.nextDown(number));
}
origin: org.apache.lucene/lucene-core

/**
 * Quantizes double (64 bit) latitude into 32 bits (rounding down: in the direction of -90)
 * @param latitude latitude value: must be within standard +/-90 coordinate bounds.
 * @return encoded value as a 32-bit {@code int}
 * @throws IllegalArgumentException if latitude is out of bounds
 */
public static int encodeLatitude(double latitude) {
 checkLatitude(latitude);
 // the maximum possible value cannot be encoded without overflow
 if (latitude == 90.0D) {
  latitude = Math.nextDown(latitude);
 }
 return (int) Math.floor(latitude / LAT_DECODE);
}
origin: org.apache.lucene/lucene-core

/**
 * Quantizes double (64 bit) longitude into 32 bits (rounding down: in the direction of -180)
 * @param longitude longitude value: must be within standard +/-180 coordinate bounds.
 * @return encoded value as a 32-bit {@code int}
 * @throws IllegalArgumentException if longitude is out of bounds
 */
public static int encodeLongitude(double longitude) {
 checkLongitude(longitude);
 // the maximum possible value cannot be encoded without overflow
 if (longitude == 180.0D) {
  longitude = Math.nextDown(longitude);
 }
 return (int) Math.floor(longitude / LON_DECODE);
}
origin: org.apache.lucene/lucene-core

/**
 * Quantizes double (64 bit) longitude into 32 bits (rounding up: in the direction of +180)
 * @param longitude longitude value: must be within standard +/-180 coordinate bounds.
 * @return encoded value as a 32-bit {@code int}
 * @throws IllegalArgumentException if longitude is out of bounds
 */
public static int encodeLongitudeCeil(double longitude) {
 GeoUtils.checkLongitude(longitude);
 // the maximum possible value cannot be encoded without overflow
 if (longitude == 180.0D) {
  longitude = Math.nextDown(longitude);
 }
 return (int) Math.ceil(longitude / LON_DECODE);
}
origin: org.apache.lucene/lucene-core

/**
 * Quantizes double (64 bit) latitude into 32 bits (rounding up: in the direction of +90)
 * @param latitude latitude value: must be within standard +/-90 coordinate bounds.
 * @return encoded value as a 32-bit {@code int}
 * @throws IllegalArgumentException if latitude is out of bounds
 */
public static int encodeLatitudeCeil(double latitude) {
 GeoUtils.checkLatitude(latitude);
 // the maximum possible value cannot be encoded without overflow
 if (latitude == 90.0D) {
  latitude = Math.nextDown(latitude);
 }
 return (int) Math.ceil(latitude / LAT_DECODE);
}
origin: vavr-io/vavr

  @GwtIncompatible("Math::nextUp is not implemented")
  static BigDecimal asDecimal(double number) {
    if (number == NEGATIVE_INFINITY) {
      final BigDecimal result = BigDecimal.valueOf(Math.nextUp(NEGATIVE_INFINITY));
      return result.subtract(INFINITY_DISTANCE.get());
    } else if (number == POSITIVE_INFINITY) {
      final BigDecimal result = BigDecimal.valueOf(Math.nextDown(POSITIVE_INFINITY));
      return result.add(INFINITY_DISTANCE.get());
    } else {
      return BigDecimal.valueOf(number);
    }
  }
}
origin: prestodb/presto

@ScalarOperator(SATURATED_FLOOR_CAST)
@SqlType(StandardTypes.REAL)
public static strictfp long saturatedFloorCastToFloat(@SqlType(StandardTypes.DOUBLE) double value)
{
  float result;
  float minFloat = -1.0f * Float.MAX_VALUE;
  if (value <= minFloat) {
    result = minFloat;
  }
  else if (value >= Float.MAX_VALUE) {
    result = Float.MAX_VALUE;
  }
  else {
    result = (float) value;
    if (result > value) {
      result = Math.nextDown(result);
    }
    checkState(result <= value);
  }
  return floatToRawIntBits(result);
}
origin: vavr-io/vavr

@GwtIncompatible
static Iterator<Double> rangeClosedBy(double from, double toInclusive, double step) {
  if (from == toInclusive) {
    return of(from);
  }
  final double toExclusive = (step > 0) ? Math.nextUp(toInclusive) : Math.nextDown(toInclusive);
  return rangeBy(from, toExclusive, step);
}
origin: prestodb/presto

@Test
public void testCastToBigint()
{
  assertFunction("cast(37.7E0 as bigint)", BIGINT, 38L);
  assertFunction("cast(-37.7E0 as bigint)", BIGINT, -38L);
  assertFunction("cast(17.1E0 as bigint)", BIGINT, 17L);
  assertFunction("cast(-17.1E0 as bigint)", BIGINT, -17L);
  assertFunction("cast(9.2E18 as bigint)", BIGINT, 9200000000000000000L);
  assertFunction("cast(-9.2E18 as bigint)", BIGINT, -9200000000000000000L);
  assertFunction("cast(2.21E9 as bigint)", BIGINT, 2210000000L);
  assertFunction("cast(-2.21E9 as bigint)", BIGINT, -2210000000L);
  assertFunction("cast(17.5E0 as bigint)", BIGINT, 18L);
  assertFunction("cast(-17.5E0 as bigint)", BIGINT, -18L);
  assertFunction("cast(" + Math.nextDown(0x1.0p63) + " as bigint)", BIGINT, (long) Math.nextDown(0x1.0p63));
  assertInvalidFunction("cast(" + 0x1.0p63 + " as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(" + Math.nextUp(0x1.0p63) + " as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(" + Math.nextDown(-0x1.0p63) + " as bigint)", INVALID_CAST_ARGUMENT);
  assertFunction("cast(" + -0x1.0p63 + " as bigint)", BIGINT, (long) -0x1.0p63);
  assertFunction("cast(" + Math.nextUp(-0x1.0p63) + " as bigint)", BIGINT, (long) Math.nextUp(-0x1.0p63));
  assertInvalidFunction("cast(9.3E18 as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(-9.3E18 as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(infinity() as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(-infinity() as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(nan() as bigint)", INVALID_CAST_ARGUMENT);
}
origin: org.elasticsearch/elasticsearch

@Override
public Query containsQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
  return DoubleRange.newContainsQuery(field,
    new double[] {includeFrom ? (Double)from : Math.nextUp((Double)from)},
    new double[] {includeTo ? (Double)to : Math.nextDown((Double)to)});
}
@Override
origin: org.elasticsearch/elasticsearch

@Override
public Query containsQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
  return FloatRange.newContainsQuery(field,
    new float[] {includeFrom ? (Float)from : Math.nextUp((Float)from)},
    new float[] {includeTo ? (Float)to : Math.nextDown((Float)to)});
}
@Override
origin: org.elasticsearch/elasticsearch

@Override
public Query withinQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
  return DoubleRange.newWithinQuery(field,
    new double[] {includeFrom ? (Double)from : Math.nextUp((Double)from)},
    new double[] {includeTo ? (Double)to : Math.nextDown((Double)to)});
}
@Override
origin: org.elasticsearch/elasticsearch

  @Override
  public Query intersectsQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
    return DoubleRange.newIntersectsQuery(field,
      new double[] {includeFrom ? (Double)from : Math.nextUp((Double)from)},
      new double[] {includeTo ? (Double)to : Math.nextDown((Double)to)});
  }
},
origin: org.elasticsearch/elasticsearch

@Override
public Query withinQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
  return FloatRange.newWithinQuery(field,
    new float[] {includeFrom ? (Float)from : Math.nextUp((Float)from)},
    new float[] {includeTo ? (Float)to : Math.nextDown((Float)to)});
}
@Override
origin: org.elasticsearch/elasticsearch

  @Override
  public Query intersectsQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
    return FloatRange.newIntersectsQuery(field,
      new float[] {includeFrom ? (Float)from : Math.nextUp((Float)from)},
      new float[] {includeTo ? (Float)to : Math.nextDown((Float)to)});
  }
},
origin: rnewson/couchdb-lucene

@Override
public Query toRangeQuery(final String name, final String lower, final String upper,
             final boolean lowerInclusive, final boolean upperInclusive) {
  return DoublePoint.newRangeQuery(name,
                   lowerInclusive ? toDouble(lower) : Math.nextUp(toDouble(lower)),
                   upperInclusive ? toDouble(upper) : Math.nextDown(toDouble(upper)));
}
origin: rnewson/couchdb-lucene

@Override
public Query toRangeQuery(final String name, final String lower, final String upper,
             final boolean lowerInclusive, final boolean upperInclusive) {
  return FloatPoint.newRangeQuery(name,
                  lowerInclusive ? toFloat(lower) : Math.nextUp(toFloat(lower)),
                  upperInclusive ? toFloat(upper) : Math.nextDown(toFloat(upper)));
}
java.langMathnextDown

Popular methods of Math

  • min
    Returns the smaller of two long values. That is, the result is the argument closer to the value of L
  • max
    Returns the greater of two long values. That is, the result is the argument closer to the value of L
  • abs
    Returns the absolute value of a long value. If the argument is not negative, the argument is returne
  • round
    Returns the closest int to the argument, with ties rounding up. Special cases: * If the argument is
  • pow
    Returns the value of the first argument raised to the power of the second argument. Special cases: *
  • sqrt
    Returns the correctly rounded positive square root of a double value. Special cases: * If the argume
  • ceil
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to th
  • floor
    Returns the largest (closest to positive infinity) double value that is less than or equal to the ar
  • random
    Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returne
  • sin
    Returns the trigonometric sine of an angle. Special cases: * If the argument is NaN or an infinit
  • cos
    Returns the trigonometric cosine of an angle. Special cases: * If the argument is NaN or an infin
  • log
    Returns the natural logarithm (base e) of a doublevalue. Special cases: * If the argument is NaN
  • cos,
  • log,
  • exp,
  • toRadians,
  • atan2,
  • log10,
  • acos,
  • tan,
  • toDegrees,
  • atan

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setScale (BigDecimal)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JCheckBox (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now