Thread: Testpad for itoa()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I made up a testbed program, as well. It has an array of about 50 numbers in total, which include at least one number from each power of 10:

    1
    12
    101
    9999
    10000
    up to 1234567890

    and about 1/3rd of them are negative.

    Before the timed run, the program (which is made into a function), runs this test. Every number is tested for accuracy with the string generated by the function. Then the timed run begins and these numbers, are chosen randomly for input.

    I had to alter iMalc's first program, but it now works fine, and is still 3 X as fast as the next fastest program (but several programs have not been tested yet). I shortened the test quantity to 10 million numbers, to save time, but still give a good spread.

  2. #2
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    @Elysia:

    If you can get rid of the extra zero in the final results, this
    is one of the functions I'd like to have as an example of
    readable algorithm for beginner.

    about:
    There is only ISO C99 with respect to that standard.
    you are right. I meant you can compile it on any machine [Mac,Linux,Win...]
    that has got a standard C99 compiler. :-)

    @quzah:
    Yes.

    @whiteflags:

    Quote Originally Posted by whiteflags View Post
    Umm, what about what iMalc has said, frktons...
    I think you've reached a plateau, so like, the only things to do are make sure
    iMalc's version is correct, and you know that it is, apparently. So, what to make
    this thread about? Did you want a function remotely C like?
    The main aim of this and previous thread is to learn some
    C syntax and some C applied to algorithm building/thinking.
    Now I'm testing if the posted versions are correct, and I'm
    asking your help to do that because I don't have all the time
    and knowledge I would.

    If I don't go wrong you posted a nice version with recursion,
    one that I'd like to be tested and learn something from.

    If you can help me, try to do it yourself, no matter the performance,
    I like the style and the concepts behind it. :-)
    Would you be so kind to adapt the function you wrote
    to the testpad and see what you get please?

    The "let's do it faster" is just for setting a challenge to
    motivate people, not the real target. I hope it is clear
    enough.

    All the compiler optimization stuff is beyond the scope
    of this thread [I am a beginner for the time being].

    @cyberfish:

    Thanks cyberfish, would you transfer all those nice points
    in something C-like? I'd appreciate it very much.
    If you have a better testpad than mine, and it would not
    be so strange, after all you have far more experience than me
    with C-stuff, please show it.
    By the way, the function you proposed is a good one,
    did you debug it for numbers smaller than 1,000?

    @zacs7:
    I would not be happy with "000,012" if I wanted "12".
    neither would I. ;-)

    @Adak:

    good to know, looking forward to seeing for some output
    and attached C-stuff.

    @User Name:

    thanks. good to know.
    Last edited by frktons; 07-09-2010 at 07:34 AM.

Popular pages Recent additions subscribe to a feed