• Post Reply Bookmark Topic Watch Topic
  • New Topic

What will be the output  RSS feed

 
Amrita Rath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All,

I am facing issue for getting the output for the below code.Please explain me:



Thanks in Advance.
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What output did you get ? What did you not understand about the output ?

Note that if you use an integer literal starting with a zero, the number is treated as being octal instead of decimal. Is that what's confusing you ?
 
Amrita Rath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes that was the confusion.Can you please guide me how I am getting the value of i=8.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know what "the number is treated as being octal" means?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

See: Octal

When you post a question, please explain exactly what your question is. Don't just say "I am facing an issue". We can't read your mind to know what your issue is.
 
Ankush Kaundal
Ranch Hand
Posts: 36
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amrita Rath wrote:yes that was the confusion.Can you please guide me how I am getting the value of i=8.


It is simple, if you convert octal value '010' to decimal then that is equivalent to 8 and that's why you are getting 8 as an output.
 
riteshhh kumar singh
Greenhorn
Posts: 13
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes that was the confusion.Can you please guide me how I am getting the value of i=8.


you have used "i=010" in your code which assigns the value 8 to the variable i,your query is how the value 8 is assigned to i.
this is how it will be converted from octal to decimal (1*8^1+0*8^0).
 
Amrita Rath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I understood now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!