public class FastDoubleParser
extends java.lang.Object
The code has been changed, so that it parses the same syntax as
Double.parseDouble(String).
References:
| Modifier and Type | Method and Description |
|---|---|
static double |
parseDouble(java.lang.CharSequence str)
Returns a Double object holding the double value represented by the
argument string
str. |
public static double parseDouble(java.lang.CharSequence str)
throws java.lang.NumberFormatException
str.
This method can be used as a drop in for method
Double.valueOf(String). (Assuming that the API of this method
has not changed since Java SE 16).
Leading and trailing whitespace characters in str are ignored.
Whitespace is removed as if by the String.trim() method;
that is, characters in the range [U+0000,U+0020].
The rest of str should constitute a FloatValue as described by the
lexical syntax rules shown below:
- FloatValue:
- [Sign]
NaN- [Sign]
Infinity- [Sign] DecimalFloatingPointLiteral
- [Sign] HexFloatingPointLiteral
- SignedInteger
- HexFloatingPointLiteral:
- HexSignificand BinaryExponent
- HexSignificand:
- HexNumeral
- HexNumeral
.0x[HexDigits].HexDigits0X[HexDigits].HexDigits
- HexSignificand:
- HexNumeral
- HexNumeral
.0x[HexDigits].HexDigits0X[HexDigits].HexDigits
- BinaryExponent:
- BinaryExponentIndicator SignedInteger
- BinaryExponentIndicator:
pP
- DecimalFloatingPointLiteral:
- Digits
.[Digits] [ExponentPart].Digits [ExponentPart]- Digits ExponentPart
- ExponentPart:
- ExponentIndicator SignedInteger
- ExponentIndicator:
- (one of)
- e E
- SignedInteger:
- [Sign] Digits
- Sign:
- (one of)
- + -
- Digits:
- Digit {Digit}
- HexNumeral:
0xHexDigits0XHexDigits
- HexDigits:
- HexDigit {HexDigit}
- HexDigit:
- (one of)
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
str - the string to be parsedjava.lang.NumberFormatException - if the string can not be parsed