Static utility methods pertaining to {@code double} primitives, that are not already found in either {@link Double} or {@link Arrays}. <p>See the Guava User Guide article on <a href="https://github.com/google/guava/wiki/PrimitivesExplained">primitive utilities</a>. @author Kevin Bourrillion @since
| 49 | * @since 1.0 |
| 50 | */ |
| 51 | @GwtCompatible |
| 52 | public final class Doubles extends DoublesMethodsForWeb { |
| 53 | private Doubles() {} |
| 54 | |
| 55 | /** |
| 56 | * The number of bytes required to represent a primitive {@code double} value. |
| 57 | * |
| 58 | * <p>Prefer {@link Double#BYTES} instead. |
| 59 | * |
| 60 | * @since 10.0 |
| 61 | */ |
| 62 | public static final int BYTES = Double.BYTES; |
| 63 | |
| 64 | /** |
| 65 | * Returns a hash code for {@code value}; obsolete alternative to {@link Double#hashCode(double)}. |
| 66 | * |
| 67 | * @param value a primitive {@code double} value |
| 68 | * @return a hash code for the value |
| 69 | */ |
| 70 | @InlineMe(replacement = "Double.hashCode(value)") |
| 71 | public static int hashCode(double value) { |
| 72 | return Double.hashCode(value); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Compares the two specified {@code double} values. The sign of the value returned is the same as |
| 77 | * that of <code>((Double) a).{@linkplain Double#compareTo compareTo}(b)</code>. As with that |
| 78 | * method, {@code NaN} is treated as greater than all other values, and {@code 0.0 > -0.0}. |
| 79 | * |
| 80 | * <p><b>Note:</b> this method simply delegates to the JDK method {@link Double#compare}. It is |
| 81 | * provided for consistency with the other primitive types, whose compare methods were not added |
| 82 | * to the JDK until JDK 7. |
| 83 | * |
| 84 | * @param a the first {@code double} to compare |
| 85 | * @param b the second {@code double} to compare |
| 86 | * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is |
| 87 | * greater than {@code b}; or zero if they are equal |
| 88 | */ |
| 89 | @InlineMe(replacement = "Double.compare(a, b)") |
| 90 | public static int compare(double a, double b) { |
| 91 | return Double.compare(a, b); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Returns {@code true} if {@code value} represents a real number. This is equivalent to, but not |
| 96 | * necessarily implemented as, {@code !(Double.isInfinite(value) || Double.isNaN(value))}. |
| 97 | * |
| 98 | * <p>Prefer {@link Double#isFinite(double)} instead. |
| 99 | * |
| 100 | * @since 10.0 |
| 101 | */ |
| 102 | @InlineMe(replacement = "Double.isFinite(value)") |
| 103 | public static boolean isFinite(double value) { |
| 104 | return Double.isFinite(value); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Returns {@code true} if {@code target} is present as an element anywhere in {@code array}. Note |