8287838: Update Float and Double to use snippets
Reviewed-by: alanb
This commit is contained in:
parent
a277590c89
commit
0e06bf3b04
src/java.base/share/classes/java/lang
@ -640,7 +640,7 @@ public final class Double extends Number
|
|||||||
* a {@code NumberFormatException} be thrown, the regular
|
* a {@code NumberFormatException} be thrown, the regular
|
||||||
* expression below can be used to screen the input string:
|
* expression below can be used to screen the input string:
|
||||||
*
|
*
|
||||||
* <pre>{@code
|
* {@snippet lang="java" :
|
||||||
* final String Digits = "(\\p{Digit}+)";
|
* final String Digits = "(\\p{Digit}+)";
|
||||||
* final String HexDigits = "(\\p{XDigit}+)";
|
* final String HexDigits = "(\\p{XDigit}+)";
|
||||||
* // an exponent is 'e' or 'E' followed by an optionally
|
* // an exponent is 'e' or 'E' followed by an optionally
|
||||||
@ -679,13 +679,14 @@ public final class Double extends Number
|
|||||||
* ")[pP][+-]?" + Digits + "))" +
|
* ")[pP][+-]?" + Digits + "))" +
|
||||||
* "[fFdD]?))" +
|
* "[fFdD]?))" +
|
||||||
* "[\\x00-\\x20]*");// Optional trailing "whitespace"
|
* "[\\x00-\\x20]*");// Optional trailing "whitespace"
|
||||||
*
|
* // @link region substring="Pattern.matches" target ="java.util.regex.Pattern#matches"
|
||||||
* if (Pattern.matches(fpRegex, myString))
|
* if (Pattern.matches(fpRegex, myString))
|
||||||
* Double.valueOf(myString); // Will not throw NumberFormatException
|
* Double.valueOf(myString); // Will not throw NumberFormatException
|
||||||
|
* // @end
|
||||||
* else {
|
* else {
|
||||||
* // Perform suitable alternative action
|
* // Perform suitable alternative action
|
||||||
* }
|
* }
|
||||||
* }</pre>
|
* }
|
||||||
*
|
*
|
||||||
* @param s the string to be parsed.
|
* @param s the string to be parsed.
|
||||||
* @return a {@code Double} object holding the value
|
* @return a {@code Double} object holding the value
|
||||||
@ -1099,13 +1100,13 @@ public final class Double extends Number
|
|||||||
* <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
|
* <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
|
||||||
* values that can be computed from the argument:
|
* values that can be computed from the argument:
|
||||||
*
|
*
|
||||||
* <blockquote><pre>{@code
|
* {@snippet lang="java" :
|
||||||
* int s = ((bits >> 63) == 0) ? 1 : -1;
|
* int s = ((bits >> 63) == 0) ? 1 : -1;
|
||||||
* int e = (int)((bits >> 52) & 0x7ffL);
|
* int e = (int)((bits >> 52) & 0x7ffL);
|
||||||
* long m = (e == 0) ?
|
* long m = (e == 0) ?
|
||||||
* (bits & 0xfffffffffffffL) << 1 :
|
* (bits & 0xfffffffffffffL) << 1 :
|
||||||
* (bits & 0xfffffffffffffL) | 0x10000000000000L;
|
* (bits & 0xfffffffffffffL) | 0x10000000000000L;
|
||||||
* }</pre></blockquote>
|
* }
|
||||||
*
|
*
|
||||||
* Then the floating-point result equals the value of the mathematical
|
* Then the floating-point result equals the value of the mathematical
|
||||||
* expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-1075</sup>.
|
* expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-1075</sup>.
|
||||||
|
@ -922,13 +922,13 @@ public final class Float extends Number
|
|||||||
* <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
|
* <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
|
||||||
* values that can be computed from the argument:
|
* values that can be computed from the argument:
|
||||||
*
|
*
|
||||||
* <blockquote><pre>{@code
|
* {@snippet lang="java" :
|
||||||
* int s = ((bits >> 31) == 0) ? 1 : -1;
|
* int s = ((bits >> 31) == 0) ? 1 : -1;
|
||||||
* int e = ((bits >> 23) & 0xff);
|
* int e = ((bits >> 23) & 0xff);
|
||||||
* int m = (e == 0) ?
|
* int m = (e == 0) ?
|
||||||
* (bits & 0x7fffff) << 1 :
|
* (bits & 0x7fffff) << 1 :
|
||||||
* (bits & 0x7fffff) | 0x800000;
|
* (bits & 0x7fffff) | 0x800000;
|
||||||
* }</pre></blockquote>
|
* }
|
||||||
*
|
*
|
||||||
* Then the floating-point result equals the value of the mathematical
|
* Then the floating-point result equals the value of the mathematical
|
||||||
* expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-150</sup>.
|
* expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-150</sup>.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user