• Alan Balkany (unregistered)

    The real WTF is the lack of comments. A close second is the undescriptive variable names.

    This function obviously has to deal with many special cases (probably as a result of a long line of WTFs) and there's really no elegant way to do it. Comments would make it understandable and maintainable.

  • msp (unregistered)

    forget all obfuscators. do it manually!

  • david (unregistered)

    VB uses a windows system dll to do rounding. This has three unfortunate side effects:

    1. Rounding in all existing VB6 applications changed when MS decided to change the rounding function from 'simple' to 'bankers'.
    2. The rounding function returns 'wrong' answers for some numbers (not n.5, but some x.xxxxxx5).
    3. The rounding function returns different numbers than Excel returns.

    Excel uses a dedicated math engine, and windows system programmers don't fool around with it. Also, for most people, Excel defines the 'correct' answer. (I don't know what kind of answer the C examples given here return: when I was doing that stuff C didn't have a standard math library)

    The odd mixture of Switch and repeated IF statements indicates either that the programmer changed, or that the programmer has been learning on the job. But since the global excel object is fully described in the IF statements, but implied in the Switch statement, I'm betting that this is the product of more than one mind.

    VB Switch statements are a powerful and flexible construct, added during the interpreted phase of the life of the language, but this Switch statement adds nothing to this code: it's just a coding style anomoly.

  • IChrisI (unregistered)

    I made a function that had that many special cases once. Of course, this was back when I was in highschool and just getting into programming...

  • anonymous coder (unregistered)

    It looks like reverse engineered code: disassembled and lazily rewritten into basic, without the finishing touch of actually making it decent to read.

  • VolodyA! V A (unregistered)

    How can anyone dislike the function which goes "Beep"?

Leave a comment on “Classic WTF: calculatethenumbers(v,w,x,y,z)”

Log In or post as a guest

Replying to comment #:

« Return to Article