Padding numbers

From: fb (fb_at_goaway.net)
Date: 11/24/04


Date: Wed, 24 Nov 2004 22:26:55 GMT

Hello Everyone. I was wondering what function I could use to pad some
input. For example, I have something like: cin >>
memory[OperationCode]; If the user enters less than 4 digits ie. '3', I
would like to add 3 zeros to the beginning of the number ie. '0003'.

I could use some if/else statements to get the size of the input...like
if(memory[OperationCode] < 10){
   cout << "000" << memory[OperationCode];
etc...

But I was hoping for a shorter way...Any Ideas?
Thanks.



Relevant Pages

  • Re: Padding numbers
    ... I was wondering what function I could use to pad some ... I have something like: cin>> ... | But I was hoping for a shorter way...Any Ideas? ... # include <iomanip> ...
    (alt.comp.lang.learn.c-cpp)
  • Interpolation And Low-Pass filtering
    ... I read that while interpolaton for upsampling we pad zeros (their ... You are basically moving "non-zero" frequency components into the ...
    (comp.dsp)
  • Re: padding zeros in char *
    ... i'll need to pad the piece with zeros until it ... 'string' at the first occurency of \0. ... Pad your last "string" with '\0' as needed and you will be fine. ...
    (comp.lang.c)
  • Google search tips please was[Re: Zero padding the frequency spectrum]
    ... As far as I have understood the FFT, it is sometimes beneficial to pad ... the time-signal with zeros to achieve an increased "resolution" (I know ... interpolation that takes place). ... with zeros to make it 1024 samples long. ...
    (comp.dsp)
  • Re: Zero padding the frequency spectrum
    ... As far as I have understood the FFT, it is sometimes beneficial to pad ... the time-signal with zeros to achieve an increased "resolution" (I know ... interpolation that takes place). ... with zeros to make it 1024 samples long. ...
    (comp.dsp)