krepta at juno.com:
> I don't understand C or C++ well enough to know what this source code
> means.  Sorry.  I need it in QBasic, at least till I learn C and C++. :)

        INPUT:  hex, binary, octal, decimal, whatever

                                ||
                                \/

        CONVERSION:        native integer

                                ||
                                \/

        OUTPUT: hex, binary, octal, decimal, whatever

That's the broad structure of the conversion program. Now, the
specific algorithms - to create an integer from hex, for instance,
or print an integer in decimal format - are really common, so you'll
have no trouble finding example code and explanations. They require
bit-level manipulation (shifts, masks, etc) so you should be
comfortable with doing that sort of thing before diving in.

There are actually only two algorithms for standard base-n numbers,
one for input and one for output. Things like roman numerals or
spelled-out numbers will require specialized algorithms, of course,
so it's a good idea to write your conversion program in an
extensible way, in case you ever need to deal with those.

Unfortunately I don't know QBasic, but I'll show you how I'd
implement the program in C if you'd like (I'll write lots of
comments).

_______________________________________________
Chat mailing list
Chat at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/chat

Reply via email to