Hexadecimal to Decimal 
	 
	
		| Author | 
		Message | 
	 
		 
		pcmang
 
 
 
    
		 | 
		
		
			
				  Posted: 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 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Insectoid
 
  
 
    
		 | 
		
		
			
				  Posted: Tue Jun 08, 2010 11:14 am    Post subject: RE:Hexadecimal to Decimal  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| How would you do this on paper, mathematically? | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		pcmang
 
 
 
    
		 | 
		
		 | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Insectoid
 
  
 
    
		 | 
		
		
			
				  Posted: 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. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |