Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Octal to Decimal Convertion

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is as such :
The numbers given are

1. int a = 056;
2. int b = 034;
3. System.out.println(a);
4. System.out.println(b);
What will the output be ? . Please explain the convertion from Octal to Decimal .
Mail me the reply at tushar_matkar@rediffmail.com
 
Enthuware Software Support
Posts: 4572
45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to check this out: http://www.tpub.com/neets/book13/53q.htm
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The output will be :
a = 46
b = 28
see http://www.macdonald.egate.net/CompSci/Pascal/hnumeration.html#octal
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java thinks in unicode. It doesn't matter if you provide input in octal, binary, decimal or what, it will get converted to unicode by java for processing. Output is provided in decimal unless you specifically force it otherwise (like with a string representation of a number in binary).
So you really didn't need to ask it to do anything special to get it converted to decimal. That is just the normal handling.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first check those above web sites ^__^* very very good and some simple examples.
here is why:
a=056, so output is 46
b/c: (8^0*6)+(8^1*5)=(1*6)+(8*5)=6+40=46
b=034, so output is 28
b/c: (8^0*4)+(8^1*3)=(1*4)+(8*3)=4+24=28
hope this help ^__^*
good day.
 
Would you like to try a free sample? Today we are featuring tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic