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

Class Doubles

output/java_guava/1.4.17/Doubles.java:51–649  ·  view source on GitHub ↗

Static utility methods pertaining to double primitives, that are not already found in either Double or Arrays. See the Guava User Guide article on primitive utilities . @author Kevin Bourrillion @since

Source from the content-addressed store, hash-verified

49
50
51@GwtCompatible(emulated = true)
52public final class Doubles {
53 private Doubles() {}
54
55 /**
56 * The number of bytes required to represent a primitive {@code double} value.
57 *
58 * @since 10.0
59 */
60
61
62 public static final int BYTES = Double.SIZE / Byte.SIZE;
63
64 /**
65 * Returns a hash code for {@code value}; equal to the result of invoking
66 * {@code ((Double) value).hashCode()}.
67 *
68 * @param value a primitive {@code double} value
69 * @return a hash code for the value
70 */
71
72
73 public static int hashCode(double value) {
74 return ((Double) value).hashCode();
75 // TODO(kevinb): do it this way when we can (GWT problem):
76 // long bits = Double.doubleToLongBits(value);
77 // return (int) (bits ^ (bits >>> 32));
78 }
79
80 /**
81 * Compares the two specified {@code double} values. The sign of the value returned is the same as
82 * that of <code>((Double) a).{@linkplain Double#compareTo compareTo}(b)</code>. As with that
83 * method, {@code NaN} is treated as greater than all other values, and {@code 0.0 > -0.0}.
84 *
85 * <p><b>Note:</b> this method simply delegates to the JDK method {@link Double#compare}. It is
86 * provided for consistency with the other primitive types, whose compare methods were not added
87 * to the JDK until JDK 7.
88 *
89 * @param a the first {@code double} to compare
90 * @param b the second {@code double} to compare
91 * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is
92 * greater than {@code b}; or zero if they are equal
93 */
94
95
96 public static int compare(double a, double b) {
97 return Double.compare(a, b);
98 }
99
100 /**
101 * Returns {@code true} if {@code value} represents a real number. This is equivalent to, but not
102 * necessarily implemented as, {@code !(Double.isInfinite(value) || Double.isNaN(value))}.
103 *
104 * @since 10.0
105 */
106
107
108 public static boolean isFinite(double value) {

Callers

nothing calls this directly

Calls 1

fpPatternMethod · 0.95

Tested by

no test coverage detected