Tell the difficulties that i am difficult.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
SCJP, SCJD, SCWCD, SCBCD, SCEA
Tell the difficulties that i am difficult.
Tell the difficulties that i am difficult.
saloni jhanwar wrote:please help me:argh:
saloni jhanwar wrote:please help me:argh:
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Dennis Deems wrote:
saloni jhanwar wrote:please help me:argh:
It might help to read this, as it explains the rationale: http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001628.html
The mail wrote:Underscores must always be between digits
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jiafan Zhou wrote:Why using underscores?
Jesper de Jong wrote:
Dennis Deems wrote:
saloni jhanwar wrote:please help me:argh:
It might help to read this, as it explains the rationale: http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001628.html
Funny. That mail also uses the number "52", exactly as Saloni in her examples. That can't be a coincidence...
And it gives the following reason why 0_52 is allowed and 0x_52 is not:
The mail wrote:Underscores must always be between digits
i.e 0x_52 is invalid because underscore was at beginning, so for octal number 0_52 underscore is also at beginning.Underscores can't go at the beginning or the end of a number.
Tell the difficulties that i am difficult.
saloni jhanwar wrote:0_52 underscore is also at beginning.
![]()
Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
Tell the difficulties that i am difficult.
Aniruddh Joshi wrote:
saloni jhanwar wrote:0_52 underscore is also at beginning.
![]()
I thought 0_52 compiled succesfully.
Tell the difficulties that i am difficult.
saloni jhanwar wrote:Thank you Jesper de Jong.I found something in JLS.
![]()
In a hexadecimal or binary literal, the integer is only denoted by the digits after the 0x or 0b characters and before any type suffix. Therefore, underscores may not appear immediately after 0x or 0b, or after the last digit in the numeral.
In a decimal or octal literal, the integer is denoted by all the digits in the literal before any type suffix. Therefore, underscores may not appear before the first digit or after the last digit in the numeral. Underscores may appear after the initial 0 in an octal numeral (since 0 is a digit that denotes part of the integer) and after the initial non-zero digit in a non-zero decimal literal.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
saloni jhanwar wrote:
Aniruddh Joshi wrote:
saloni jhanwar wrote:0_52 underscore is also at beginning.
![]()
I thought 0_52 compiled succesfully.
Yes,it will be compile successfully because compiler is not treating it as octal number.It is being treat as decimal number.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Tell the difficulties that i am difficult.
Jelle Klap wrote:There's nothing else to explain, really. Like Jesper said, this is simply how it's defined in the JLS.
Dennis Deems wrote:Actually, it helped me rather a lot to learn that the intent of the underscores is merely to enhance human readability of long values. I don't see that anywhere in the JLS.
Underscores are allowed as separators between digits that denote the integer
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jelle Klap wrote:It actually pretty much is.
Underscores are allowed as separators between digits that denote the integer
Separators, in the context of numbers, are usually intended for the sole purpose of improving readability, no?
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|