Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting from hex to decimal

 
Ross Gayle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish to know if there are any simple conversion techniques of integral values from hex (0x7fffffff) to decimal (2147483647) . it can be quite useful in solving questions.

thx....
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you like this?

 
Ross Gayle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i meant solving by hand.
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hexadecimal<-->Binary and Octal<-->Binary is very easy and zero arithematic is needed for that.
As a next step Hexadecimal<-->Octal is also easy if we use binary as a bridge.

All of above works without tedious arithematic.

To do decimal<-->binary a little arithmatic seems to be a must.
If that is not an issue then again binary can be used as a bridge to achieve hexa<-->decimal.

This is what I learnt recently.
[ June 09, 2004: Message edited by: Swamy Nathan ]
 
maha devan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

U can find the hand solving of Different Conversions in books like
Digital Electronics by Moris Mano
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do they have any nonarithematic based direct solution for hexa<-->decimal in the book?
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am copypasting a portion of my notes I built up recetnly based on some material referrred here.
If anyone gives a non-arithematic way for hexadecimal<-->decimal I would also be glad.


[ June 09, 2004: Message edited by: Swamy Nathan ]
 
Ross Gayle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for that info Mr. Swamy. It was quite useful. I knew the way to do it , just was checking to see if a better way existed.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ross,

Welcome to Javaranch

We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call me just "Swamy".
I for one didnt know it and learnt this at this forum only.
I too would like to know if there is any way to do the hexa<-->decimal stuff directly.
Maybe someone else like me would find it more useful.


[ June 09, 2004: Message edited by: Swamy Nathan ]
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow Guys !

Very thorough, but luckily the exam is no where near this hard.

The most important thing is to understand two's complement really well, and then understand hex and octal at a high level. You WON'T have to do lots of calculations on the exam, for instance, if you know that -3 in binary has lots of 1111111's you should be in good shape. The other important thing to understand is the shift operators.

If you know two's complement and shifting, go study another section.

- Bert
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Glad it wont be tough.

Its just that alittle insight on how it works helps. Insight is helped from examples (and observing the examples) and viceversa. Dont know about the exam but I found it useful in a few mock test questions. I think I will trust Bert about the exam (fingers crossed) since he wrote a few books and all.

I sometimes overflow with concepts and had a spillover I guess.

Must be the cofee again.
SCJP
[ June 09, 2004: Message edited by: Swamy Nathan ]
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's really hard for people who write the mock exams to know EXACTLY what's on the exam - so in general I think mock exams tend to be broader than the real exam. I think that Dan Chisolm amended his mocks after taking the exam to more accurately reflect what's really on the exam.

We also had a thread on this forum a while back - you can search for it - something like 'top ten things you think are on the exam but aren't'

Good luck!

-Bert
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just thought I should complete the picture

 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bert Bates:
It's really hard for people who write the mock exams to know EXACTLY what's on the exam - so in general I think mock exams tend to be broader than the real exam. I think that Dan Chisholm amended his mocks after taking the exam to more accurately reflect what's really on the exam.

We also had a thread on this forum a while back - you can search for it - something like 'top ten things you think are on the exam but aren't'

Good luck!

-Bert



Yes, that is correct. I developed my mock exam to prepare for the real exam. After passing the real exam, I removed a lot of mock exam questions that were far too difficult or were far beyond the scope of the real exam. What is left are questions that are just a little more difficult than the real exam, and some of the questions might still be just a little beyond the scope of the real exam. Even with this new simplified version of my exam, most people still score higher on the real exam.
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I have been fretting about my scores in ur mocks. So its comforting to hear that.
 
Nobuhiro Watsuki
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Id do it like this:

123 hex:

(1*16^2) + (2*16^1) + (3*16^0) = the decimal number
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think using "Nobuhiro Watsuki"'s way will cause problems when you try to convert from a byte say FF which is -1 or a short say FFFF again -1. I dont know for sure if there is any other way around.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic