Does anyone know of any tutorials on how to convert a string of characters from dec to hex to oct and bin? If there are no tutorials, could someone give me the gist of it? Doesnt have to be code either, pseudo-code would be cool too.
Posted on 2001-11-13 17:18:54 by ChimpFace9000
I don't know about oct, but converting between hex,dec, and bin isn't that hard. Decimal can easily be converted to hex, and hex can easily be converted to binary. Try reading the Art Of Assembly, it clears everything up regarding those three bases (again I don't no much about oct, so..) good luck :alright:
Posted on 2001-11-13 19:05:39 by Eagle17
I have a hard copy of AoA, it explains pretty good on how to convert a string to a number, but not how to convert a string to another base.
Posted on 2001-11-13 19:23:39 by ChimpFace9000
Here is a link to X-Calibre's Page, please look at this algorithm. He has many other great works here as well!
Posted on 2001-11-13 20:16:01 by bitRAKE
there are a couple of proc's in the masm32\m32lib directory (atodw and hextodw i think)
Posted on 2001-11-20 16:53:08 by huh

but not how to convert a string to another base.

string->machine representation of number.
machine representation of number->string in new base.

Posted on 2001-11-20 17:39:29 by f0dder
There was an article, with code, in the Assembly Language Journal, for converting between some 64-bit bases. If you can't find it, let me know and I'll try and locate it.
Posted on 2001-11-21 04:16:30 by Dwayne Childers
Do you need fastest algos of subj or just theory?
The thing is that in the best algos there a big way was done
with math and low level optimization and simple theory
wouldn't be enough to understand the state of the art realization.
Posted on 2001-11-27 09:29:09 by The Svin
I had the blow the dust off of the piece of work (I made it over 6 months ago). It will convert Dec to any base from 0 to 16.

print &Base(174,16);

sub Base {
(my $Dec, my $Base) = @_;
my $Hex;
while ($Dec > 0)
{$Hex = (sprintf "%1.1X", ($Dec % $Base)) . $Hex; $Dec = int $Dec / $Base}
return $Hex }

With a little modification, this sub will do the reverse (hint: change / to *).
Posted on 2001-11-28 04:57:22 by eet_1024
You are doing one pointless iteration
condition must be While num > base.
Last num will be already Base^0 * k AKA - last digit
Posted on 2001-11-28 06:32:12 by The Svin
I'm not going to take the time to mess with it, but I think I did it that way so that the last digit gets appended within the loop; instead of copying the code and pasting after the loop. However, it doesn't add an extra digit to the string.
Posted on 2001-11-29 04:10:02 by eet_1024