• 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

How to convert hexadecimal to decimal /integer ?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...
my question is too basic...
but i am confused...
just tell me
How to convert hexadecimal to decimal /integer ?
means ...
oX7fffffff = 2147483647
how can i calculate this ?

this topic is from first chapter of kathy's book ...
[ January 04, 2007: Message edited by: Kavita Kale ]
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have Khalid Mughals book for 1.4, you have a dedicated topic as an Appendix. You can easily google out your querry and you'll find numerous links explaining this.
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make a Integer object like
Integer ii = new Integer(oX7fffffff);
//get the int value.
System.out.prinltn(ii.intValue());
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually is not necessary to use a wrapper class like Integer.

You can just use:

int a = 0xA;

System.out.println(a);

-----------------------------

The most important thing to remember maybe is you are not converting the data. You are just seeing it from a different point of view.

Internally the PC sees your data as binary. But it is still the same.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

doing it manually will help you more to understand.
It basically works like binary, except the base is 16.

For example:
0xbad
b*16^2 + a*16^1 + d*16^0
= 11*256 + 10*16 + 13*1
= 2816 + 160 + 13
= 2989
 
Kavita Kale
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tommaso...
its very helpful to me....
now i am feeling i am perfect in this topic.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It basically works like binary, except the base is 16.


True - but don't forget about the sign bit...
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And remember, this is only important for the 1.4 exam - it's NOT on the 5.0 exam
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bert Bates:
And remember, this is only important for the 1.4 exam - it's NOT on the 5.0 exam


You took this off the 1.5 exam??? ppffff!!! These kids today don't have to learn ANYTHING, do they?

 
expectation is the root of all heartache - shakespeare. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic