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

How to use
signum
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.signum (Showing top 20 results out of 4,797)

origin: libgdx/libgdx

/** Determines on which side of the given line the point is. Returns -1 if the point is on the left side of the line, 0 if the
 * point is on the line and 1 if the point is on the right side of the line. Left and right are relative to the lines direction
 * which is linePoint1 to linePoint2. */
public static int pointLineSide (Vector2 linePoint1, Vector2 linePoint2, Vector2 point) {
  return (int)Math.signum(
    (linePoint2.x - linePoint1.x) * (point.y - linePoint1.y) - (linePoint2.y - linePoint1.y) * (point.x - linePoint1.x));
}
origin: libgdx/libgdx

  static private int computeSpannedAreaSign (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) {
    float area = p1x * (p3y - p2y);
    area += p2x * (p1y - p3y);
    area += p3x * (p2y - p1y);
    return (int)Math.signum(area);
  }
}
origin: libgdx/libgdx

  static private int computeSpannedAreaSign (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) {
    float area = p1x * (p3y - p2y);
    area += p2x * (p1y - p3y);
    area += p3x * (p2y - p1y);
    return (int)Math.signum(area);
  }
}
origin: libgdx/libgdx

/** Determines on which side of the given line the point is. Returns -1 if the point is on the left side of the line, 0 if the
 * point is on the line and 1 if the point is on the right side of the line. Left and right are relative to the lines direction
 * which is linePoint1 to linePoint2. */
public static int pointLineSide (Vector2 linePoint1, Vector2 linePoint2, Vector2 point) {
  return (int)Math.signum(
    (linePoint2.x - linePoint1.x) * (point.y - linePoint1.y) - (linePoint2.y - linePoint1.y) * (point.x - linePoint1.x));
}
origin: libgdx/libgdx

public static int pointLineSide (float linePoint1X, float linePoint1Y, float linePoint2X, float linePoint2Y, float pointX,
  float pointY) {
  return (int)Math
    .signum((linePoint2X - linePoint1X) * (pointY - linePoint1Y) - (linePoint2Y - linePoint1Y) * (pointX - linePoint1X));
}
origin: libgdx/libgdx

public static int pointLineSide (float linePoint1X, float linePoint1Y, float linePoint2X, float linePoint2Y, float pointX,
  float pointY) {
  return (int)Math
    .signum((linePoint2X - linePoint1X) * (pointY - linePoint1Y) - (linePoint2Y - linePoint1Y) * (pointX - linePoint1X));
}
origin: libgdx/libgdx

  @Override
  public int compare (Decal o1, Decal o2) {
    float dist1 = camera.position.dst(o1.position);
    float dist2 = camera.position.dst(o2.position);
    return (int)Math.signum(dist2 - dist1);
  }
});
origin: libgdx/libgdx

  @Override
  public int compare (Decal o1, Decal o2) {
    float dist1 = camera.position.dst(o1.position);
    float dist2 = camera.position.dst(o2.position);
    return (int)Math.signum(dist2 - dist1);
  }
});
origin: prestodb/presto

@Description("round to integer by dropping digits after decimal point")
@ScalarFunction
@SqlType(StandardTypes.REAL)
public static long truncate(@SqlType(StandardTypes.REAL) long num)
{
  float numInFloat = intBitsToFloat((int) num);
  return floatToRawIntBits((float) (Math.signum(numInFloat) * Math.floor(Math.abs(numInFloat))));
}
origin: prestodb/presto

@Description("round to integer by dropping digits after decimal point")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double truncate(@SqlType(StandardTypes.DOUBLE) double num)
{
  return Math.signum(num) * Math.floor(Math.abs(num));
}
origin: prestodb/presto

@Description("signum")
@ScalarFunction("sign")
@SqlType(StandardTypes.REAL)
public static long signFloat(@SqlType(StandardTypes.REAL) long num)
{
  return floatToRawIntBits((Math.signum(intBitsToFloat((int) num))));
}
origin: prestodb/presto

@LiteralParameters({"p", "s"})
@SqlType("decimal(1,0)")
public static long signDecimalShort(@SqlType("decimal(p, s)") long num)
{
  return (long) Math.signum(num);
}
origin: prestodb/presto

@ScalarFunction
@SqlType(StandardTypes.BIGINT)
public static long sign(@SqlType(StandardTypes.BIGINT) long num)
{
  return (long) Math.signum(num);
}
origin: google/guava

public void testCompare() {
 // This is the only ordering for primitives that does not have a
 // corresponding Comparable wrapper in java.lang.
 for (int i = 0; i < VALUES.length; i++) {
  for (int j = 0; j < VALUES.length; j++) {
   byte x = VALUES[i];
   byte y = VALUES[j];
   // note: spec requires only that the sign is the same
   assertEquals(
     x + ", " + y,
     Math.signum(UnsignedBytes.compare(x, y)),
     Math.signum(Ints.compare(i, j)));
  }
 }
}
origin: prestodb/presto

private void testCompare(String decimalA, String decimalB, int expected)
{
  int actual = TYPE.compareTo(decimalAsBlock(decimalA), 0, decimalAsBlock(decimalB), 0);
  assertEquals((int) signum(actual), (int) signum(expected), "bad comparison result for " + decimalA + ", " + decimalB);
}
origin: prestodb/presto

@Description("signum")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double sign(@SqlType(StandardTypes.DOUBLE) double num)
{
  return Math.signum(num);
}
origin: prestodb/presto

@Description("signum")
@ScalarFunction("sign")
@SqlType(StandardTypes.INTEGER)
public static long signInteger(@SqlType(StandardTypes.INTEGER) long num)
{
  return (long) Math.signum(num);
}
origin: prestodb/presto

@Description("signum")
@ScalarFunction("sign")
@SqlType(StandardTypes.SMALLINT)
public static long signSmallint(@SqlType(StandardTypes.SMALLINT) long num)
{
  return (long) Math.signum(num);
}
origin: prestodb/presto

@Description("signum")
@ScalarFunction("sign")
@SqlType(StandardTypes.TINYINT)
public static long signTinyint(@SqlType(StandardTypes.TINYINT) long num)
{
  return (long) Math.signum(num);
}
origin: apache/kafka

public void verifyReauthenticationMetrics(int successfulReauthentications, final int failedReauthentications)
    throws InterruptedException {
  waitForMetrics("successful-reauthentication", successfulReauthentications,
      EnumSet.of(MetricType.TOTAL, MetricType.RATE));
  waitForMetrics("failed-reauthentication", failedReauthentications,
      EnumSet.of(MetricType.TOTAL, MetricType.RATE));
  waitForMetrics("successful-authentication-no-reauth", 0, EnumSet.of(MetricType.TOTAL));
  waitForMetrics("reauthentication-latency", Math.signum(successfulReauthentications),
      EnumSet.of(MetricType.MAX, MetricType.AVG));
}
java.langMathsignum

Javadoc

Returns the signum function of the argument. If the argument is less than zero, it returns -1.0. If the argument is greater than zero, 1.0 is returned. If the argument is either positive or negative zero, the argument is returned as result.

Special cases:

  • signum(+0.0) = +0.0
  • signum(-0.0) = -0.0
  • signum(+infinity) = +1.0
  • signum(-infinity) = -1.0
  • signum(NaN) = NaN

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

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Best plugins for Eclipse
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