Mail Archives: djgpp/1998/10/05/10:05:29
tomstdenis AT my-dejanews DOT com wrote:
> > I have 2 numbers 12 (18) and
> > 212 (d4) and I want to convert
> > them into one number.
> >
> > I know the number I want is 6356
> > but i don't know how to get it.
> > Can someone send me the right
> > code?
Actually no, you only have one number, which in C syntax is 0x18d4.
Conversion between bases, especially between base 10 and base 2 or 16 is a
common operation. Any math text will have the algorithm. If you must show your
work, that's the route to take. You may find it useful to be able to determine
the remainder from an integer division. Look at the % operator.
OTOH, this is something that is commonly done in programs--debuggers, for
example. Given the nature of programmers, perhaps it wouldn't surprise you to
learn that the standard library will do this for you quite neatly, with little
muss or fuss. If you're not required to show your work, that would be MUCH
easier.
Have fun!
Charles
- Raw text -