Help coderanch get a
new server
by contributing to the fundraiser
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Jeanne Boyarsky
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Rob Spoor
• Devaka Cooray
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Frits Walraven
• Tim Moores
Bartenders:
• Mikalai Zaikin

# Explanation needed for this program

Greenhorn
Posts: 13
• Number of slices to send:
Optional 'thank-you' note:

Why every times 16 is display? can any one explain me this?

Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
I suspect Java decides you want to see the result in decimal.

EDIT:

If you're unsure what octal, decimal and hexadecimal means, check out:

http://mathworld.wolfram.com/Octal.html

lowercase baba
Posts: 13091
67
• Number of slices to send:
Optional 'thank-you' note:
Any numeric literal that starts with a "0" is considered to be written in Octal - or base 8. That means you can only use the digits from 0-7, and each position represents powers of 8.

Literals that begin with "0x" are considered Hexadecimal, which means you can use the digits 0-9 plus A-F. Each position represents a power of 16.

This sounds weird, but makes perfect sense for computers and representing things stored in computers.

Java Cowboy
Posts: 16084
88
• 1
• Number of slices to send:
Optional 'thank-you' note:

Arvind Kurmi wrote:Why every times 16 is display? can any one explain me this?

Did you expect something else? For example, did you expect that it would display "0x10" when you initialize the integer with 0x10?

Note that decimal, octal and hexadecimal are just different ways to represent numbers. But the number itself it just a number and nothing more: it does not have some property that says that the number is decimal, octal or hexadecimal. In other words, the variable doesn't know anything about how you wrote it in your source code.

Arvind Kurmi
Greenhorn
Posts: 13
• Number of slices to send:
Optional 'thank-you' note:
Adam Johansson, fred rosenberger , Jesper de Jong.
thanks
it was really helpful

 Did you miss me? Did you miss this tiny ad? We need your help - Coderanch server fundraiser https://coderanch.com/t/782867/Coderanch-server-fundraiser