• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

How to convert hexadecimal to decimal /integer ?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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: 12911
64
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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: 9000
19
  • Mark post as helpful
  • send pies
  • 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: 12911
64
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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?

 
Always look on the bright side of life. At least this ad is really tiny:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic