Re: Binary to Hexadecimal Conversion



lei wrote:
It's working now. Another problem:

Enter a number in binary: 10000011
Hexadecimal: 00000000000000000083

How can I remove the zeros?

A very good question!

Take yourself off the keyboard for a few minutes, maybe actually use a pen[cil] and paper to work through the inherent logic of the challenge.

Think along the lines of, "Hmm, what conditions pertain when a am preparing to output a '0' that would require me to display it? What conditions would allow me to suppress it?" (Hint: One of the conditions is that the numeral to display at the moment is '0'.)

Then detect those conditions in your code, and either emit or decline to emit the '0' as appropriate.

- Lew
.



Relevant Pages

  • Re: Changing keyboard symbols
    ... that on the character map window, ... means to display any ASCII character. ... keyboard with 100 keys, you have a number pad and you use ... simulate a numeric pad, see your laptop manual. ...
    (microsoft.public.windowsxp.hardware)
  • re: X11 & console setup
    ... >> monitor the primary display. ... >> on the console so I'm not sure what will happen here. ... >> grab the keyboard and mouse unless you have a second keyboard. ... don't make it part of your Xinerama display. ...
    (freebsd-questions)
  • Re: OT: MacBook
    ... It's nothing like what you have in Agent. ... has a standard hierarchial display of threads. ... By mouse, I have to move my hand away from the keyboard, find the mouse ... hit Command-W, then Command-Option-K, done. ...
    (uk.rec.motorcycles)
  • Re: Graphic options for DS10L
    ... when the system is at the>>> prompt. ... The LCD display reports that ... I don't yet have a keyboard ... Is there a way to get the system to use the serial port as "keyboard"? ...
    (comp.os.vms)
  • Re: Remote Access
    ... computer's keyboard and display to check up on it, tweak the process, ... If I read the XP help files properly, it would seem that the cruncher ... If someone sold third party software that would let me control the machine remotely, then I'd be happy to find space for it in a closet somewhere. ...
    (microsoft.public.windowsxp.basics)