Support Underscores in Numbers (java7)
--------------------------------------
Key: QDOX-185
URL: http://jira.codehaus.org/browse/QDOX-185
Project: QDox
Issue Type: Improvement
Components: Parser
Reporter: Robert Scholte
Assignee: Robert Scholte
Priority: Minor
For details see
http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001628.html
Some examples:
{code}
long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumbers = 999_99_9999L;
float monetaryAmount = 12_345_132.12;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xFFEC_DE5E;
long maxLong = 0x7fff_ffff_ffff_ffffL;
long alsoMaxLong = 9_223_372_036_854_775_807L;
double whyWouldYouEverDoThis = 0x1_.ffff_ffff_ffff_fp10_23;
// Additionally, if binary literals are ever added to the Java language, the
following might also be possible...
byte nybbles = 0b0010_0101;
long bytes = 0b11010010_01101001_10010100_10010010;
int weirdBitfields = 0b000_10_101;
// Note that according to this proposal, underscores can only be placed between
digits. They cannot be placed by themselves in positions where a string of
digits would normally be expected:
int x1 = _52; // This is an identifier, not a numeric literal.
int x2 = 5_2; // OK. (Decimal literal)
int x2 = 52_; // Illegal. (Underscores must always be between digits)
int x3 = 5_______2; // OK. (Decimal literal.)
int x4 = 0_x52; // Illegal. Can't put underscores in the "0x" radix prefix.
int x5 = 0x_52; // Illegal. (Underscores must always be between digits)
int x6 = 0x5_2; // OK. (Hexadecimal literal)
int x6 = 0x52_; // Illegal. (Underscores must always be between digits)
int x6 = 0x_; // Illegal. (Not valid with the underscore removed)
int x7 = 0_52; // OK. (Octal literal)
int x7 = 05_2; // OK. (Octal literal)
int x8 = 052_; // Illegal. (Underscores must always be between digits)
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email