Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Hexadecimal to Decimal
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
pcmang




PostPosted: Tue Jun 08, 2010 10:23 am   Post subject: Hexadecimal to Decimal

I dont know how to create the processing/return method for this :S
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Jun 08, 2010 11:14 am   Post subject: RE:Hexadecimal to Decimal

How would you do this on paper, mathematically?
pcmang




PostPosted: Tue Jun 08, 2010 2:56 pm   Post subject: Re: Hexadecimal to Decimal

You dont know? Heres an example...not a good one tho. :S

http://www.ehow.com/how_5059936_convert-hexadecimal-decimal.html
Insectoid




PostPosted: Tue Jun 08, 2010 3:07 pm   Post subject: RE:Hexadecimal to Decimal

I do know, I was asking if you know. I'm assuming you do, so it's just a matter of turning that into code.



The easiest way is to iterate over each element in the hex string (I'm assuming you're using a string for this) and search for that digit in a pre-defined array of elements 1-9, A-F (where each element is at the index corresponding to its decimal equivalent).

There are much better ways of doing it that allow any base -> any base, but for hex -> dec only it's faster to just hard-code in the array.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: