src/share/classes/java/lang/Double.java

Print this page

        

*** 451,462 **** * * <p>To avoid calling this method on an invalid string and having * a {@code NumberFormatException} be thrown, the regular * expression below can be used to screen the input string: * ! * <code> ! * <pre> * final String Digits = "(\\p{Digit}+)"; * final String HexDigits = "(\\p{XDigit}+)"; * // an exponent is 'e' or 'E' followed by an optionally * // signed decimal integer. * final String Exp = "[eE][+-]?"+Digits; --- 451,461 ---- * * <p>To avoid calling this method on an invalid string and having * a {@code NumberFormatException} be thrown, the regular * expression below can be used to screen the input string: * ! * <pre>{@code * final String Digits = "(\\p{Digit}+)"; * final String HexDigits = "(\\p{XDigit}+)"; * // an exponent is 'e' or 'E' followed by an optionally * // signed decimal integer. * final String Exp = "[eE][+-]?"+Digits;
*** 472,482 **** * // * // Since this method allows integer-only strings as input * // in addition to strings of floating-point literals, the * // two sub-patterns below are simplifications of the grammar * // productions from section 3.10.2 of ! * // <cite>The Java&trade; Language Specification</cite>. * * // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt * "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+ * * // . Digits ExponentPart_opt FloatTypeSuffix_opt --- 471,481 ---- * // * // Since this method allows integer-only strings as input * // in addition to strings of floating-point literals, the * // two sub-patterns below are simplifications of the grammar * // productions from section 3.10.2 of ! * // The Java Language Specification. * * // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt * "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+ * * // . Digits ExponentPart_opt FloatTypeSuffix_opt
*** 497,508 **** * if (Pattern.matches(fpRegex, myString)) * Double.valueOf(myString); // Will not throw NumberFormatException * else { * // Perform suitable alternative action * } ! * </pre> ! * </code> * * @param s the string to be parsed. * @return a {@code Double} object holding the value * represented by the {@code String} argument. * @throws NumberFormatException if the string does not contain a --- 496,506 ---- * if (Pattern.matches(fpRegex, myString)) * Double.valueOf(myString); // Will not throw NumberFormatException * else { * // Perform suitable alternative action * } ! * }</pre> * * @param s the string to be parsed. * @return a {@code Double} object holding the value * represented by the {@code String} argument. * @throws NumberFormatException if the string does not contain a
*** 754,766 **** /** * Returns a hash code for a {@code double} value; compatible with * {@code Double.hashCode()}. * ! * @since 1.8 ! * * @return a hash code value for a {@code double} value. */ public static int hashCode(double value) { long bits = doubleToLongBits(value); return (int)(bits ^ (bits >>> 32)); } --- 752,764 ---- /** * Returns a hash code for a {@code double} value; compatible with * {@code Double.hashCode()}. * ! * @param value the value to hash * @return a hash code value for a {@code double} value. + * @since 1.8 */ public static int hashCode(double value) { long bits = doubleToLongBits(value); return (int)(bits ^ (bits >>> 32)); }