MCPcopy Create free account
hub / github.com/antlr/codebuff / roundToInt

Method roundToInt

output/java_guava/1.4.16/DoubleMath.java:124–129  ·  view source on GitHub ↗

Returns the int value that is equal to x rounded with the specified rounding mode, if possible. @throws ArithmeticException if x is infinite or NaN x, after being rounded to a mathematical integer using the specified rounding mode, is

(double x, RoundingMode mode)

Source from the content-addressed store, hash-verified

122 */
123
124 @GwtIncompatible // #roundIntermediate
125 public static int roundToInt(double x, RoundingMode mode) {
126 double z = roundIntermediate(x, mode);
127 checkInRange(z > MIN_INT_AS_DOUBLE - 1.0 & z < MAX_INT_AS_DOUBLE + 1.0);
128 return (int) z;
129 }
130
131 private static final double MIN_INT_AS_DOUBLE = -0x1p31;
132 private static final double MAX_INT_AS_DOUBLE = 0x1p31 - 1.0;

Callers

nothing calls this directly

Calls 2

roundIntermediateMethod · 0.95
checkInRangeMethod · 0.45

Tested by

no test coverage detected