IntelliJ Java IDE
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes conversion from hex to decimal Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "conversion from hex to decimal" Watch "conversion from hex to decimal" New topic
Author

conversion from hex to decimal

kishen uchil
Greenhorn

Joined: Aug 21, 2000
Posts: 14
please tell me how do u convert a hex number 0xFEB8 to decimal.
the actual answer is -328.but i dont know how it is done.

hi there chetan.but in the book "exam cram"
pg 43 its given:
DECIMAL HEX
343 0x157
275 0x0113
-328 0xFEB8
the first two i can understand but the last
one differs from your answer.please help.
[This message has been edited by kishen uchil (edited August 30, 2000).]
chetan nain
Ranch Hand

Joined: Jun 21, 2000
Posts: 159
remember the folln table:
DecimalBinaryOctalHexadecimal
00000000
10000111
20001022
30001133
40010044
50010155
60011066
70011177
801000108
901001119
100101012A
110101113B
120110014C
130110115D
140111016E
150111117F
16100002010
����
����
����
Conversion of hex to dec:
your example: 0xFEB8
F*(16^3)+ E*(16^2) + B*(16^1) + 8*(10^0)
lookup of hex values F,E,B in above table
yields 17,16 and 11 resp.
substituting,
17*(16^3)+ 16*(16^2) + 11*(16^1) + 8*(10^0)
answer:65208
HTH,
chetan
kishen uchil
Greenhorn

Joined: Aug 21, 2000
Posts: 14
hi there chetan.but in the book "exam cram"
pg 43 its given:
DECIMAL HEX
343 0x157
275 0x0113
-328 0xFEB8
the first two i can understand but the last
one differs from your answer.please help.
chetan nain
Ranch Hand

Joined: Jun 21, 2000
Posts: 159
you may try it :
System.out.println(0xFEB8);
gives 65208
am i missing something here?
seeknew
Greenhorn

Joined: Aug 25, 2000
Posts: 11
-328 when converted to hex in windows calculator gives FFFFFEB8.
So it might be due to the negative sign. please check it out. It may be 2's complement, 1's complement or something similar to that, I am not sure.
kishen uchil
Greenhorn

Joined: Aug 21, 2000
Posts: 14
hi there chetan.im sorry man u were right.actually -328 equates
to 0xfffffeb8 in hex .the book was wrong.thanks very much for the help.
 
 
subject: conversion from hex to decimal
 
Threads others viewed
Hexadecimal
Octal
Outputting Number is Hex Format
hexadecimal numbers
number converstion between(decimal, octal, Hex)
developer file tools