

Subject:
Convert LARGE decimal numbers to Hex
Category: Computers > Algorithms Asked by: ricjohnsoniiiga List Price: $55.00 
Posted:
09 May 2005 20:34 PDT
Expires: 08 Jun 2005 20:34 PDT Question ID: 519786 

There is no answer at this time. 

Subject:
Re: Convert LARGE decimal numbers to Hex
From: quadraticresiduega on 11 May 2005 13:33 PDT 
I am not sure what you mean by "magic number". It looks like you might be referring to the following algorithm for square root: http://www.dattalo.com/technical/theory/sqrt.html As the author notes, the algorithm is similar to long division, so I can't see why you object to using long division. 
Subject:
Re: Convert LARGE decimal numbers to Hex
From: idoivriga on 16 May 2005 00:50 PDT 
might this help you? http://www.permadi.com/tutorial/numConvJs/ It's a nice number converter from / to  Dec/Bin/Hex that converts your number as you type it. I tried it with some numbers I have and it worked fine. I. 
Subject:
Re: Convert LARGE decimal numbers to Hex
From: ricjohnsoniiiga on 16 May 2005 13:30 PDT 
Regarding http://www.permadi.com/tutorial/numConvJs/ This number converted is limited to 15 digits. It uses the internal MATH methods and native data types to convert to HEX. I am looking for something that can convert a LARGE number  assume at least 30 digits. 
Subject:
Re: Convert LARGE decimal numbers to Hex
From: thefistofthenorthstaga on 31 May 2005 18:50 PDT 
Here's some code I just cooked up. Should do the trick. No magic numbers though. /************************************************ * This function decodes a decimal string and * returns a hexadecimal string. There is no * size limit on the decimal input. ************************************************/ function dec2hex(dec) { //Create a buffer for the hexadecimal var hex = new Array( Math.ceil( dec.length * 0.83048202372184058696757985737235 )); //Initialize as 0 for(var i=0; i<hex.length; i++) hex[i] = 0; //Create raw binary number in hex for(var i=0; i<dec.length; i++) { //Multiply by 10 for(var j=0; j<hex.length; j++) hex[j] *= 10; //Add character hex[0] += parseInt(dec.charAt(i)); //Carry for(var j=0; j < hex.length; j++) if(hex[j] > 16) { hex[j + 1] += Math.floor(hex[j] / 16); hex[j] = hex[j] % 16; } } //Convert raw binary to hex var hex_chars = "0123456789abcdef"; //Strip leading zeros var index = hex.length  1; while(hex[index] == 0 && index > 0) index; //Append the hexadecimal digits var result = hex_chars.charAt(hex[0]); for(var i=1; i <= index; i++) result = hex_chars.charAt(hex[i]) + result; //Done return result; } 
Subject:
Re: Convert LARGE decimal numbers to Hex
From: ricjohnsoniiiga on 03 Jun 2005 11:09 PDT 
I am sorry, I tried to code this, but it did not work for LARGE numbers (50+ digits). Can you clarify the code with comments for each step (I may have coded it wrong). 1) Does the step "//Multiply by 10" encounter an overflow? 2) Why do you work from the lwft (signigicant digits)? 3) This seems the same as long division  can you explain? 
If you feel that you have found inappropriate content, please let us know by emailing us at answerssupport@google.com with the question ID listed above. Thank you. 
Search Google Answers for 
Google Home  Answers FAQ  Terms of Service  Privacy Policy 