• 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
  • 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

Conversion

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does anyone know how to convert Hexadecimal to Decimal & octal to decimal?If so,please help me.
Thanks
rubna
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rubna,
For Decimal to Octal:
----------------------------
Hope you know that ,for Octal the base value is "8" and allowed digits are 0,1,2,3,4,5,6,7.
For example let us take decimal value 138
Divide this number by the Octal base value and quotient becomes not divisible by base value.
so 138/8 ie the remainder is 2 and Quotient is 17.
Then divide the quotient by 8 ie(17/8) the remainder is 1 and quotient is 2 and this can not be divided
again and so write the answers only including last quotient to the first remainder.
For example in this case 0212 is the Octal value for Decimal 138.

For Octal to Decimal:
----------------------------
Powers of 8 will come into picture.
For example in this the Octal Number is 0212.
2 X 8^0 +1 X 8^1 + 2 X 8 ^ 2 ,the MSB ,here is the Octal indication digit. and it will not have any impact on
the conversion.
The result is 2 + 8 + 128 = 138.
Hope this can help you and for better understanding you have to work out by yourself.
For Hexam decimal use Base 16 and digits are 0 to 9,a,b,c,d,e,f(ie 0 to 15).
For Hexa decimal representation prefix is 0X(Zero X).
The conversion process is the same and so you can try on that.
Hope it helps you.
Thanks
Nirmal

 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rubna:
Hi,
Does anyone know how to convert Hexadecimal to Decimal & octal to decimal?If so,please help me.
Thanks
rubna


You can use the methods in the Integer Wrapper class

 
rubna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Carl Trusiak:
[B]
[/B]


Thsnks a lot Carl.
 
rubna
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nirmal:
Hi Rubna,
For Decimal to Octal:


Thanks a lot.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic