A DESCRIPTION OF THE REQUEST :
From the Javadoc for Integer.decode(String) in Java 7.
DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java™ Language Specification, except that underscores are not accepted between digits.
However, this section defines a format new to Java 7; BinaryNumeral
A binary numeral consists of the leading ASCII characters 0b or 0B followed by one or more of the ASCII digits 0 or 1 interspersed with underscores, and can represent a positive, zero, or negative integer.
For consistency, this method should decode BinaryNumeral as well.
JUSTIFICATION :
For consistency.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Decode binary numerals.
ACTUAL -
Throws a NumberFormatException
---------- BEGIN SOURCE ----------
int i = 0b1010101;
int j = Integer.decode("0b1010101");
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Parse such Strings without calling this method.
From the Javadoc for Integer.decode(String) in Java 7.
DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java™ Language Specification, except that underscores are not accepted between digits.
However, this section defines a format new to Java 7; BinaryNumeral
A binary numeral consists of the leading ASCII characters 0b or 0B followed by one or more of the ASCII digits 0 or 1 interspersed with underscores, and can represent a positive, zero, or negative integer.
For consistency, this method should decode BinaryNumeral as well.
JUSTIFICATION :
For consistency.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Decode binary numerals.
ACTUAL -
Throws a NumberFormatException
---------- BEGIN SOURCE ----------
int i = 0b1010101;
int j = Integer.decode("0b1010101");
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Parse such Strings without calling this method.
- duplicates
-
JDK-6863378 Project Coin: Consider library support for underscores in numbers and binary literals
-
- Closed
-