get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

  • Zunetang 2012-04-16 09:33
    tl;dr - dan rather just pist frost.
  • DaveK 2012-04-16 09:33
    Passed as a perimeter? Sounds kinda edgy to me.
  • MikeN 2012-04-16 09:36
    My favorite part is that it's version 15.1.
  • 3rd Ferguson 2012-04-16 09:37
    I thought we frowned on using student code as WTFs.

    //CAPTCHA: "inhibeo" - the spell that causes Hermione to get nervous and put her robe back on
  • M 2012-04-16 09:38
    This function just skirts the issue...

    Captcha: feugiat - feugiataboutit
  • KattMan 2012-04-16 09:39
    Honestly it's a language parser, should be easy to do all numbers with little more code.

    Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
    After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

    Yeah this function is a serious WTF, even in its name, sounds like the forgot to name it and just put the comment as the name.
  • Anon 2012-04-16 09:40
    I love how schizophrenic this is. On the one hand you've got a variable named "WORD_CONVERTED_FROM_A_NUMBER_PASSED_THROUGH_A_PERIMETER", but on the other hand you have "HX_373".

    It's like a epic battle between overly long descriptive variable names and short, completely cryptic variable names, fighting for the soul of this function.
  • Julia 2012-04-16 09:40
    I can't wait for the future version that handles up to 10^8...
  • DaveK 2012-04-16 09:40
    MikeN:
    My favorite part is that it's version 15.1.
    And "enterprise edition", no less!
  • configurator 2012-04-16 09:41
    KattMan:
    Honestly it's a language parser, should be easy to do all numbers with little more code.

    Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
    After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

    Yeah this function is a serious WTF, even in its name, sounds like the forgot to name it and just put the comment as the name.


    "Eightteen" for 18 would be better than "four" for 5, I guess... (see "bugs fixed")
  • Anon 2012-04-16 09:43
    'Establish p_mode to define correct perimeter
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If

    If p_mode = "No perimeter was passed through" Then
    p_mode = ""
    Else
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If
    End If


    I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.
  • GoodtimesSnuggler 2012-04-16 09:44
    I like the bugs fixed

    "'Shortened name of the function due to errors on polling the function"

    THIS IS THE SHORTER NAME?!
  • Coyne 2012-04-16 09:47
    Enterprisey. Very enterprisey. Also shtupid.
  • NickS 2012-04-16 09:48
    At one of my previous jobs they hired a new guy not because he was qualified in any way for the job, but solely on the basis that he used to be a Russian rocket scientist during the Cold War.

    Instead of doing the things required of his job, he spent 8 hours a day making calendars in MS Paint with various decorations for each month, printing them out, and handing them to everyone in the department. If he made a change to one month, he reprinted everything out again for everyone and went around swapping out the old calendars for the new ones.

    He was fired in two weeks. For some reason, seeing this code reminded me of him. Good intentions, poor execution, completely irrelevant to the task at hand.
  • ubersoldat 2012-04-16 09:50

    Patched this function so that mode offers expert perimeter settings for advanced programmers


    Yeah right!
  • Bruce W 2012-04-16 09:53
    One of my elementary school teachers told me if I am going to spell a word wrong at least keep the same spelling throughout what I am writing. Glad to see someone else took that lesson to heart. (yes, yes "perimeter" is a real word...)
  • Quirkafleeg 2012-04-16 09:55
    I like the fact that the first bug fixer could spell "three" but thought "eleevn" was a perfectly acceptable number.
  • TGV 2012-04-16 09:56
    THE BUG FIXES! THE BUG FIXES!! OMG, THEY DO NOTHING!!
  • Rafael Giusti 2012-04-16 09:56
    > Passed as a perimeter? Sounds kinda edgy to me.

    TUDUM TSS!!!
  • Decius 2012-04-16 09:58
    Anon:
    'Establish p_mode to define correct perimeter
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If

    If p_mode = "No perimeter was passed through" Then
    p_mode = ""
    Else
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If
    End If


    I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.


    Not quite nothing- if you pass "no perimeter ...", it changes to an empty string.

    Granted, it doesn't do anything remotely useful, but that's not the same thing as a NOP.
  • Michal 2012-04-16 09:59
    He meant definitely "parameter" when writing "perimeter". Then it starts making sense.
  • C-Octothorpe 2012-04-16 09:59
    Anon:
    I love how schizophrenic this is. On the one hand you've got a variable named "WORD_CONVERTED_FROM_A_NUMBER_PASSED_THROUGH_A_PERIMETER", but on the other hand you have "HX_373".

    It's like a epic battle between overly long descriptive variable names and short, completely cryptic variable names, fighting for the soul of this function.
    *golf clap*
  • Bleat 2012-04-16 10:02
    'API call removed due to high demand


    1) How much was this used that this was ever in 'high demand'
    2) What kind of API call would this even use? What's more, would it actually have been useful?
  • Weps 2012-04-16 10:02

    "... Please try again"


    Hahaha
  • Doug 2012-04-16 10:09
    Time for this programmer to enter the ranks of management and spend the rest of his/her career saying how "we used to do it."
  • Steve The Cynic 2012-04-16 10:10
    If you ask me, whoever wrote it was just taking the piss. It would be worth the submitter's while, I think, to search for calls to this.

    In code that's reachable from somewhere reachable, if you get my drift...
  • KattMan 2012-04-16 10:11
    Ok Code challenge!

    Challenge A: write one that can handle conversion of numerics to text without range failures (we can limit at somewhere around the millions? billions?) in the fewest lines possible.

    Challenge B: write one that still gives the answer but in the most convoluted way.

    Challenge C: By far the easiest, do one or the other challenges but in a way that we can't tell what you were going for.
  • Jaunticed 2012-04-16 10:14
    I'm banking on this being just a joke. Evidence?

    'Shortened name of the function due to errors on polling the function

    Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.
  • PiisAWheeL 2012-04-16 10:15
    Decius:
    Anon:
    'Establish p_mode to define correct perimeter
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If

    If p_mode = "No perimeter was passed through" Then
    p_mode = ""
    Else
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If
    End If


    I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.


    Not quite nothing- if you pass "no perimeter ...", it changes to an empty string.

    Granted, it doesn't do anything remotely useful, but that's not the same thing as a NOP.
    My thoughts exactly. But it also made my eyes bleed.

    'Shortened name of the function due to errors on polling the function
    Shortened it from what?!
  • Prosthetic Lips 2012-04-16 10:16
    Michal:
    He meant definitely "parameter" when writing "perimeter". Then it starts making sense.


    True, but since this function was for a dictionary and spell checker, that makes it even more ironic!
  • _rnd 2012-04-16 10:18
    get_comment_from_a_number_and_post_comment_to_function_and_submit_to_website_tdwtf()
  • Spider Flyer 2012-04-16 10:19
    Wow...

    ...How old is this code? Because I saw _working_ code that would do this in a '79 or '80 copy of 'Creative Computing'.

    Also, you can find working code online if you search for a one of the 'large' number suffixes plus the name of your favorite computer language.

    For example, while searching for 'septillion c#', I found: http://www.vb-helper.com/howto_net_number_to_words2.html

  • the beholder 2012-04-16 10:22
    MikeN:
    My favorite part is that it's version 15.1.
    I bet that "bug fixes" section is gonna be quite long by the time he puts 10^8 in the range.

    Whoever wrote this code should be thrown out the window... of a orbital station.
  • KattMan 2012-04-16 10:25
    the beholder:
    MikeN:
    My favorite part is that it's version 15.1.
    I bet that "bug fixes" section is gonna be quite long by the time he puts 10^8 in the range.

    Whoever wrote this code should be thrown out the window... of a orbital station.


    In a degrading orbit or with exiting force?
  • geoffrey, MCP, PMP 2012-04-16 10:25
    Jaunticed:
    I'm banking on this being just a joke. Evidence?

    'Shortened name of the function due to errors on polling the function

    Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.


    One of Visual Basic's many useful features is an Eval function, which executes any text string you hand to it as code. The original author is probably using Eval, and has discovered a limitation on length for the argument.
  • vt_mruhlin 2012-04-16 10:31
    'Sometimes a 'four' would be outputted when '5' was passed through the perimeter

    Can we all take a moment to imagine just how bad the original version of this must have been if that particular problem only reproed sometimes?
  • KattMan 2012-04-16 10:34
    vt_mruhlin:
    'Sometimes a 'four' would be outputted when '5' was passed through the perimeter

    Can we all take a moment to imagine just how bad the original version of this must have been if that particular problem only reproed sometimes?


    Was this a problem, perhaps when 5 breeched rthe perimeter one was actually removed by security. This could be expected behaviour.
  • da Doctah 2012-04-16 10:35
    KattMan:
    Honestly it's a language parser, should be easy to do all numbers with little more code.

    Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
    After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

    Did you learn that when you were threeteen, or wait until you turned fiveteen?
  • PedanticCurmudgeon 2012-04-16 10:38
    Steve The Cynic:
    If you ask me, whoever wrote it was just taking the piss. It would be worth the submitter's while, I think, to search for calls to this.

    In code that's reachable from somewhere reachable, if you get my drift...
    I was thinking the same thing when I saw the response.write in the middle of the function.
  • KattMan 2012-04-16 10:41
    da Doctah:
    KattMan:
    Honestly it's a language parser, should be easy to do all numbers with little more code.

    Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
    After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

    Did you learn that when you were threeteen, or wait until you turned fiveteen?


    I learned it back when I was eleventeen!
  • ObiWayneKenobi 2012-04-16 10:45
    Looks like something Nagesh would write; isn't that the type of Hinglish that he writes in?
  • Anketam 2012-04-16 10:47
    GoodtimesSnuggler:
    I like the bugs fixed

    "'Shortened name of the function due to errors on polling the function"

    THIS IS THE SHORTER NAME?!
    I had the identical reaction.
  • Anonymous 2012-04-16 10:50
    Really? I didn't learn it until eleventyone.
  • toth 2012-04-16 10:53
    I like that he replaces the empty string with that useless string...but only when the parameter is the empty string.

    Because assigning literals to parameters is for suckers.
  • Tim 2012-04-16 11:02
    obviously a hoax, but a hilarious one :-)

    the 'bug fixed' is the best part

  • Kasper 2012-04-16 11:20
    configurator:
    better than "four" for 5, I guess... (see "bugs fixed")
    Given the look of the code it is not surprising that such a bug could have slipped in. What scares me is that it only happened sometimes.
  • big picture thinker 2012-04-16 11:28
    p_comment = "Guys take it easy on him. He obviously never dealt with perimeters before and was just experimenting with this advanced technology. I'd like to see any of you implement a function that uses perimeters!"
    If p_comment = "" Then
    p_comment = ""
    Else
    p_comment = p_comment
    End If
  • mschaad 2012-04-16 11:44
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]

    Also, to render numbers correctly as words (with the hyphens and everything) is a harder trick than you might think.
    Thankfully, standard English style dictates that you pretty much never spell out any numbers above nine.

    So where would you need a library like this, unless your app writes checks?
  • itsmo 2012-04-16 11:56
    Seriously, did no one else notice "forteen"
  • dogmatic 2012-04-16 12:08
    Firing's too good for this clown. I do believe a hanging's in order.
  • Fractalsaremylife 2012-04-16 12:11
    The level of wrong in this is fractal. No matter how deep you go there is always more wrongness to find.

    inb4 incredibly overused inception joke.
  • Cad Delworth 2012-04-16 12:13
    Tim:
    obviously a hoax, but a hilarious one :-)
    Not necessarily. It could be a near-direct conversion from a COBOL program for converting numbers into 'amounts in words' to print out on bank cheques. I once had to write something similar (but rather better than the OP's version, obviously!).
  • MeesterTurner 2012-04-16 12:21
    MikeN:
    My favorite part is that it's version 15.1.


    What about the fact that it's the Enterprise Edition? I'd hate to see the Lite Edition...
  • Cad Delworth 2012-04-16 12:26
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]
    In the USA, yes, BUT:

    [UKGrammarNazi]
    In the UK, 13,387,281 rendered as words should read "thirteen million, three hundred and eighty-seven thousand, two hundred and eighty-one" (yes, including the commas).
    [/UKGrammarNazi]

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."

    I wish someone would have the guts to just call their variant of the language "American," since many of the idioms, phraseology, and even words are not English in the sense that any UK speaker would understand. For example, try asking for a "fanny pack" in a shop in England and see what you get (possibly including being thrown out of the shop!).
  • Anymouse 2012-04-16 12:31
    C'mon. The number of VB fails is approaching the number of VB "programmers" in the world. They're hardly worth mentioning any more. Programmers need software engineers to tell them what to do, otherwise they end up writing crap. Software engineers do not allow VB in their engineered creations. Ergo, virtually all VB is crap.

    A real WTF would be any well-written VB, since that's an infinitely rarer animal.

    Captcha: minim -- the amount of education necessary to write VB.
  • Mason Wheeler 2012-04-16 12:34
    the beholder:
    MikeN:
    My favorite part is that it's version 15.1.
    I bet that "bug fixes" section is gonna be quite long by the time he puts 10^8 in the range.

    Whoever wrote this code should be thrown out the window... of a orbital station.

    You crazy? That would screw up the structural integrity of the whole place!

    Much better to use an airlock.
  • sod 2012-04-16 12:41
    Cad Delworth:
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]
    In the USA, yes, BUT:

    [UKGrammarNazi]
    In the UK, 13,387,281 rendered as words should read "thirteen million, three hundred and eighty-seven thousand, two hundred and eighty-one" (yes, including the commas).
    [/UKGrammarNazi]

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."

    I wish someone would have the guts to just call their variant of the language "American," since many of the idioms, phraseology, and even words are not English in the sense that any UK speaker would understand. For example, try asking for a "fanny pack" in a shop in England and see what you get (possibly including being thrown out of the shop!).


    Give me a moment to put on my rubbers before I give you your fanny pack.
  • Peter 2012-04-16 12:43
    Michal:
    He meant definitely "parameter" when writing "perimeter". Then it starts making sense.
    No shit, Sherlock?
  • F 2012-04-16 12:47
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]

    Also, to render numbers correctly as words (with the hyphens and everything) is a harder trick than you might think.
    Thankfully, standard English style dictates that you pretty much never spell out any numbers above nine.

    So where would you need a library like this, unless your app writes checks?


    You clearly don't know about standard English style in writing numbers. AFAICT you are confusing it with standard American style.
  • Larry 2012-04-16 12:50
    Oh, I see it now. It should be:

    get_words_from_a_number_which_is_past_as_a_perimeter_into_this_function
  • Jack 2012-04-16 12:54
    vt_mruhlin:
    'Sometimes a 'four' would be outputted when '5' was passed through the perimeter

    Can we all take a moment to imagine just how bad the original version of this must have been if that particular problem only reproed sometimes?
    That was probably before he fixed it by putting in all the "p_mode = p_mode" stuff.
  • Risky 2012-04-16 12:55
    Spider Flyer:
    Wow...

    ...How old is this code? Because I saw _working_ code that would do this in a '79 or '80 copy of 'Creative Computing'.

    Also, you can find working code online if you search for a one of the 'large' number suffixes plus the name of your favorite computer language.

    For example, while searching for 'septillion c#', I found: http://www.vb-helper.com/howto_net_number_to_words2.html



    In '79 or '80 would you really have had enough memory to waste 73 characters on the name of the function?
  • Jay 2012-04-16 12:59
    Decius:
    Anon:
    'Establish p_mode to define correct perimeter
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If

    If p_mode = "No perimeter was passed through" Then
    p_mode = ""
    Else
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If
    End If


    I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.


    Not quite nothing- if you pass "no perimeter ...", it changes to an empty string.

    Granted, it doesn't do anything remotely useful, but that's not the same thing as a NOP.


    Ha ha! Excellent point! This is exactly the sort of thing that, if I was trying to clean up the function, would have me wondering, Is there some call where an insane person actually passed in "no perimeter ...", and if I cleaned up the code, I'd break that call.
  • rudraigh 2012-04-16 13:01
    Coyne:
    Enterprisey. Very enterprisey. Also shtupid.

    Hmm ... that would be an Arte-fact.
  • KattMan 2012-04-16 13:01
    Anymouse:
    C'mon. The number of VB fails is approaching the number of VB "programmers" in the world. They're hardly worth mentioning any more. Programmers need software engineers to tell them what to do, otherwise they end up writing crap. Software engineers do not allow VB in their engineered creations. Ergo, virtually all VB is crap.

    A real WTF would be any well-written VB, since that's an infinitely rarer animal.

    Captcha: minim -- the amount of education necessary to write VB.

    So you are saying that without logic changes this code would be ok if only it were in C or C#?
    And any engineer that is not designing in a language agnostic fashion is doing it wrong. Design is agnostic, and it shouldn't matter the language just as long as design is followed.
  • Ryan 2012-04-16 13:05
    mschaad:
    So where would you need a library like this, unless your app writes checks?
    I worked with a guy (long ago) who had to write exactly that for a COBOL shop. He tediously generated code for all the common words and punctuation, all in capital letters of course because the mainframe printer didn't do lower case.

    Problem is, this was a government facility, so the check amounts were usually pretty big numbers. And those printers that don't do lower case don't do fonts either. So before long the text wouldn't fit in the allotted space. The fix, sadly, was to print the numeric amount both in the box where it originally was, and on the "text" line.

    I don't know if he ever recovered from seeing all that work go to waste.
  • mschaad 2012-04-16 13:11
    Sorry for the imprecision. I indeed meant "standard American English style", meaning "what you use in writing," as opposed to "what you use in math." So I suppose I should have said "standard (American) writing style."

    And yes, you can include the commas in American English too, if you like. Just make sure to get those hyphens in there. ;-)
  • Jay 2012-04-16 13:13
    There is some dumb coding that at least I can comprehend. Like, when I've had to write a function like this, I've always created an array for 1 to 20 and then pulled the text from the array so it can be done with one line of code rather than a long if/then/else. But I can comprehend someone just not thinking of that, and writing the if/then/else.

    But what in the world motivates someone to write "p_mode=p_mode"? Was he concerned that there might be some situation where p_mode<>p_mode? Did he have a bug where p_mode didn't appear to contain the right value, and so, just to be sure you know, he set it to itself?

    There are some mistakes that indicate failure to think through the implications, or to consider beter alternatives, or maybe just a moment of sloppiness. But other mistakes ... I can only ask, Do you know what a computer is for?
  • LANMind 2012-04-16 13:21
    geoffrey, MCP, PMP:
    Jaunticed:
    I'm banking on this being just a joke. Evidence?

    'Shortened name of the function due to errors on polling the function

    Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.


    One of Visual Basic's many useful features is an Eval function, which executes any text string you hand to it as code. The original author is probably using Eval, and has discovered a limitation on length for the argument.


    There hasn't been an eval in VB since v6.
  • Anon 2012-04-16 13:21
    Jay:
    But what in the world motivates someone to write "p_mode=p_mode"? Was he concerned that there might be some situation where p_mode<>p_mode? Did he have a bug where p_mode didn't appear to contain the right value, and so, just to be sure you know, he set it to itself?


    Obviously it supposed to be for thread safety. In case p_mode changes between retrieving the value and setting it back again.
  • Tasty 2012-04-16 13:24
    KattMan:
    Honestly it's a language parser, should be easy to do all numbers with little more code.

    Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
    After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

    Yeah this function is a serious WTF, even in its name, sounds like the forgot to name it and just put the comment as the name.


    Never depend on logic when using natural languages!

    Your 13-19 range doesn't quite work. For example:

    three+teen != "thirteen"
    five+teen != "fifteen"

    Bonus Spanish language oddity:
    The "hundreds" in Spanish have an irregular 500.

    cien (100)
    dos cientos (200)
    tres cientos (300)
    ...
    quinentos (500) (the first N is N+~)
  • Tasty 2012-04-16 13:30
    Cad Delworth:
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]
    In the USA, yes, BUT:

    [UKGrammarNazi]
    In the UK, 13,387,281 rendered as words should read "thirteen million, three hundred and eighty-seven thousand, two hundred and eighty-one" (yes, including the commas).
    [/UKGrammarNazi]

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."

    I wish someone would have the guts to just call their variant of the language "American," since many of the idioms, phraseology, and even words are not English in the sense that any UK speaker would understand. For example, try asking for a "fanny pack" in a shop in England and see what you get (possibly including being thrown out of the shop!).


    Ask for an American rubber and you'll prevent pregnancy.

    The Canadians use our "phraseology" and your spelling. so, maybe that's the common English.
  • squidfood 2012-04-16 13:30
    Ah, I see someone's found some of Ada Lovelace's old code:

    Function 1 - In which our values are initialized, and we meet our hero, the object X



  • coyo 2012-04-16 13:34
    DaveK:
    Passed as a perimeter? Sounds kinda edgy to me.


    ++
  • LANMind 2012-04-16 13:39
    Anymouse:
    C'mon. The number of VB fails is approaching the number of VB "programmers" in the world. They're hardly worth mentioning any more. Programmers need software engineers to tell them what to do, otherwise they end up writing crap. Software engineers do not allow VB in their engineered creations. Ergo, virtually all VB is crap.

    A real WTF would be any well-written VB, since that's an infinitely rarer animal.

    Captcha: minim -- the amount of education necessary to write VB.


    I automatically assume that anyone who blames bad code on the language is as dumb as tits on bull as an analyst. There is a possibility that you're just an an elitist jackass, however.
  • ¯\(°_o)/¯ I DUNNO LOL 2012-04-16 13:41
    Yeah, I remember ol' HX_373. He was THX_1138's granddad, ya know. And when he got to drinking, he would get as pissed as a parameter!
  • Nagesh 2012-04-16 13:46
    I am not seeing a problem here. It is always being recommened to use long names for better code clarification, even names of perineters and function.
  • Nagesh 2012-04-16 13:48
    ObiWayneKenobi:
    Looks like something Nagesh would write; isn't that the type of Hinglish that he writes in?


    Exception because Nagesh kabhi VB mein programming nahi karta!!! :}
  • Strolskon 2012-04-16 13:49
    Jay:
    Decius:
    Anon:
    'Establish p_mode to define correct perimeter
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If

    If p_mode = "No perimeter was passed through" Then
    p_mode = ""
    Else
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If
    End If


    I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.


    Not quite nothing- if you pass "no perimeter ...", it changes to an empty string.

    Granted, it doesn't do anything remotely useful, but that's not the same thing as a NOP.


    Ha ha! Excellent point! This is exactly the sort of thing that, if I was trying to clean up the function, would have me wondering, Is there some call where an insane person actually passed in "no perimeter ...", and if I cleaned up the code, I'd break that call.

    It could still be replaced for a single line though.
  • no 2012-04-16 13:55
    Bleat:
    'API call removed due to high demand

    1) How much was this used that this was ever in 'high demand'


    Well, it never was defined what kind of 'high demand' - as in 'all his colleagues demanded that his hands be separated from his arms before being allowed near a computer again'
  • Zylon 2012-04-16 13:59
    MeesterTurner:
    What about the fact that it's the Enterprise Edition?

    The Enterprise edition was slightly better than the Reliant edition, but much worse than the Excelsior edition.
  • geoffrey, MCP, PMP 2012-04-16 14:05
    Anymouse:
    C'mon. The number of VB fails is approaching the number of VB "programmers" in the world. They're hardly worth mentioning any more. Programmers need software engineers to tell them what to do, otherwise they end up writing crap. Software engineers do not allow VB in their engineered creations. Ergo, virtually all VB is crap.

    A real WTF would be any well-written VB, since that's an infinitely rarer animal.

    Captcha: minim -- the amount of education necessary to write VB.


    *sigh*

    To accept this argument, one would have to ignore the fact that Visual Basic applications have delivered more business value, in the aggregate, than all other platforms combined.
  • Zylon 2012-04-16 14:05
    Cad Delworth:
    [UKGrammarNazi]
    In the UK, 13,387,281 rendered as words should read "thirteen million, three hundred and eighty-seven thousand, two hundred and eighty-one" (yes, including the commas).
    [/UKGrammarNazi]

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."

    Get over yourself, ignorant limey. The form with the ands is in fact exactly how I, an American, was taught to write out large numbers. If they're being left out, that's just laziness and/or ignorance, something that members of your own population are equally susceptible to.

    You also seem to have a shaky grasp of the proper application of "so-called".
  • geoffrey, MCP, PMP 2012-04-16 14:06
    LANMind:
    geoffrey, MCP, PMP:
    Jaunticed:
    I'm banking on this being just a joke. Evidence?

    'Shortened name of the function due to errors on polling the function

    Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.


    One of Visual Basic's many useful features is an Eval function, which executes any text string you hand to it as code. The original author is probably using Eval, and has discovered a limitation on length for the argument.


    There hasn't been an eval in VB since v6.
    Which is why this re-envisioned ".Net" pales in comparison to classic Visual Basic.
  • radarbob 2012-04-16 14:10
    I had a coworker (not student, not off-the-street-rookie) who used the same "style" to code if/else. That is, he didn't seem to know that an else clause is not required. He also like to phrase the if-condition as a negative.

    When I tried to explain this to him he said "why are you telling me this."
  • rick 2012-04-16 14:14
    And did no one notice that the example at the end uses the word "and" incorrectly in the number?
  • Gavin 2012-04-16 14:35
    Here is my quick attempt at a proper implementation of this function in Python. Note that I'm using the American method without 'and'.
  • Croswold 2012-04-16 14:38
    Zylon:

    Get over yourself, ignorant limey. The form with the ands is in fact exactly how I, an American, was taught to write out large numbers. If they're being left out, that's just laziness and/or ignorance, something that members of your own population are equally susceptible to.

    You also seem to have a shaky grasp of the proper application of "so-called".


    I was taught to write it out without "and." The justification is that "and" adds nothing. The number is perfectly intelligible with or without.

    Since "and" is way of reading "+" ("1 + 1 = 2" can be read as "one and one is two"), then really, you could put as many "and's" as you wanted.
  • Gavin 2012-04-16 14:43
    I'd also like to add that this wikipedia article seems to agree that omitting the "and" is valid in American English.
  • Nigel 2012-04-16 14:50
    This function's great because it goes all the way to eleevn
  • Neuratypical 2012-04-16 14:53
    Zylon:
    Cad Delworth:
    [UKGrammarNazi]
    In the UK, 13,387,281 rendered as words should read "thirteen million, three hundred and eighty-seven thousand, two hundred and eighty-one" (yes, including the commas).
    [/UKGrammarNazi]

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."

    Get over yourself, ignorant limey. The form with the ands is in fact exactly how I, an American, was taught to write out large numbers. If they're being left out, that's just laziness and/or ignorance, something that members of your own population are equally susceptible to.

    You also seem to have a shaky grasp of the proper application of "so-called".

    Check you out, all grammary and shit.
  • dkf 2012-04-16 14:57
    Cad Delworth:
    I wish someone would have the guts to just call their variant of the language "American,"
    That's why you have “en_GB” and “en_US” locales.
  • Matt 2012-04-16 15:03
    MikeN:
    My favorite part is that it's version 15.1.

    15 typos fixed plus one edited comment
  • Matt Westwood 2012-04-16 15:15
    Larry:
    Oh, I see it now. It should be:

    get_words_from_a_number_witch_is_past_as_a_perimeter_into_this_function


    FTFY
  • Fred 2012-04-16 15:16
    radarbob:
    I had a coworker (not student, not off-the-street-rookie) who used the same "style" to code if/else. That is, he didn't seem to know that an else clause is not required. He also like to phrase the if-condition as a negative.

    When I tried to explain this to him he said "why are you telling me this."
    I think I knew him, sorta! He left before I arrived, but his code lived on. The usual pattern:

    If not (condition) else ...

    That's right, no then clause, just straight to the else.

    I asked my coworkers if they had ever questioned him. Yes, they had. Many times. The only answer he ever offered was "for readability."
  • Kammat 2012-04-16 15:44
    Heck, is it even returning anything beyond the "bad perimeter" message? It looks like it checks if p_mode = "pass_a_number," and only starts crunching to text if it does match.
  • Ben Jammin 2012-04-16 15:49
    Cad Delworth:

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."


    One thing I dislike is improperly embedded quotation marks. Does that use different rules across the pond as well?

    By the way, "loathe" is a pretty heavy word. I'd loathe someone who shot my dog or burnt my house. Getting that angry over grammar rules that we Americans supposedly don't even know of anyways and much less follow points to other issues in the psyche.
  • Coder 2012-04-16 15:50
    I do love it when a method is self-commenting.
  • Somebody 2012-04-16 15:54
    I actually felt good about the code below when I wrote it a long time ago. Converting a dollar amount to text for a check. Reading it today, I am glad we didn't have many zero dolllar checks coming through.

    private const string DOLLARS_AND = " DOLLARS AND ";
    private const string CENTS = " CENTS";
    private const string HUNDRED = " HUNDRED";
    private const string THOUSAND = " THOUSAND";
    private const string MILLION = " MILLION";
    private string[] strNonIrtyNumberText = {" ZERO"," ONE"," TWO"," THREE"," FOUR"," FIVE",
    " SIX"," SEVEN"," EIGHT"," NINE"," TEN"," ELEVEN",
    " TWELVE"," THIRTEEN"," FOURTEEN"," FIFTEEN",
    " SIXTEEN"," SEVENTEEN"," EIGHTEEN"," NINETEEN"};
    private string[] strIrtyNumberText = {" ZERO"," TEN"," TWENTY"," THIRTY"," FORTY"," FIFTY",
    " SIXTY"," SEVENTY"," EIGHTY"," NINETY"};

    private void ConvertAmountToText(decimal decCheckAmount)
    {
    string Temp = "";
    int intDollarAmount = (int)decCheckAmount;
    int intIntegerWholeAmount = int.Parse(((int)(decCheckAmount * 100)).ToString());
    int intCents = intIntegerWholeAmount - (intDollarAmount * 100);
    string strDollarAmount = intDollarAmount.ToString().PadLeft(7, '0');

    if (intDollarAmount == 0)
    Temp = strNonIrtyNumberText[0] + DOLLARS_AND + intCents.ToString().PadLeft(2, '0') + CENTS;

    int intCheckOne;
    int intCheckTwo;
    int intCheckTeen;
    bool bolIrtyValue = false;

    for (int x = 0; x < 7; x++)
    {
    intCheckOne = int.Parse(strDollarAmount[x].ToString());
    intCheckTwo = x == 6 ? 0 : int.Parse(strDollarAmount[x + 1].ToString());
    intCheckTeen = int.Parse(intCheckOne.ToString() + intCheckTwo.ToString());
    //0000000
    if (intCheckOne != 0)
    {
    if (x == 2 || x == 5)
    bolIrtyValue = true;

    if (bolIrtyValue && intCheckTeen < 20)
    Temp += strNonIrtyNumberText[intCheckTeen];
    else if (bolIrtyValue && intCheckTeen > 19)
    { Temp += strIrtyNumberText[intCheckOne]; Temp += intCheckTwo == 0 ? "" : strNonIrtyNumberText[intCheckTwo]; }
    else
    Temp += strNonIrtyNumberText[intCheckOne];

    if (bolIrtyValue)
    x++;

    Temp += x == 0 ? MILLION : "";
    Temp += x == 1 || x == 4 ? HUNDRED : "";
    Temp += x == 3 && intDollarAmount > 999 ? THOUSAND : "";

    }
    Temp += x == 6 ? DOLLARS_AND : "";
    bolIrtyValue = false;
    }
    Temp += intCents.ToString().PadLeft(2, '0') + CENTS;
    return = Temp.Trim();
    }
  • zzo38 2012-04-16 16:04
    @. --- English numbers ---

    @0
    There is another thing controlled by the \.{(English)} parameter.
    Converting numbers to words is also conditionally enabled. These can be
    grouped into three kinds: ``1'' to ``one'', ``1'' to ``first'', and ``1''
    to ``1st''.

    @E English
    (English)L
    @<

    @0
    The last case, ``1'' to ``1st'', is simplest, so it comes first.

    @S 1_1st
    @. ( number -- text )
    <[th]s0[st]s1[nd]s2[rd]s3
    dBr
    100%d10%r10/1-1 0 1i*
    d3-1d0i*
    `0+L+>

    @0
    The other two are also simple, if they are done using a word form table.
    So, that is what we will do. Word form table 1 will be used for numbers
    into words.

    @W
    #1

    2:0]:]
    2:1]:one
    2:2]:two
    2:3]:three
    2:4]:four
    2:5]:five
    2:6]:six
    2:7]:seven
    2:8]:eight
    2:9]:nine
    3:10]:ten
    3:11]:eleven
    3:12]:twelve
    3:13]:thirteen
    3:14]:fourteen
    3:15]:fifteen
    3:16]:sixteen
    3:17]:seventeen
    3:18]:eighteen
    3:19]:nineteen
    4:2t]:twenty
    4:3t]:thirty
    4:4t]:forty
    4:5t]:fifty
    4:6t]:sixty
    4:7t]:seventy
    4:8t]:eighty
    4:9t]:ninety
    5:-th]:th
    5:ty-th]:tieth
    5:one-th]:first
    5:two-th]:second
    5:three-th]:third
    5:five-th]:fifth
    5:eight-th]:eighth
    5:nine-th]:ninth
    5:twelve-th]:twelvth

    @0
    Now we have the definition for \.{(1\_one)} and \.{(1\_first)}. The second
    one is mostly like the first one, so it will call the first one. You
    should not input negative numbers to these subroutines, because it will
    just assume it is zero.

    @S 1_one
    @. ( number -- text )
    d[D[zero]]d[<s1
    l1100%B1WD@. Get words for number 1-19
    l1100%20-[](1_one_20to99)dix@. Deal with prefix for 20-90
    l1100/10%s2[hundred](1_one_1000)x@. Deal with hundreds
    l11000/1000%s2[thousand](1_one_1000)x@. Deal with thousands
    l11000000/1000%s2[million](1_one_1000)x@. Deal with millions
    l11000000000/s2[billion](1_one_1000)x@. Deal with billions
    >]ix

    @S 1_one_20to99
    AD@. Remove the tens digit left from before
    l110/10%B[t]+1WD@. Make word for 20-90
    rdZ0[][-]ir+@. Figure out whether a hyphen should be added
    +@. Join the tens word with the ones word

    @S 1_one_1000
    l20[D][
    l2(1_one)x@. A recursive call, get word for this number
    [ ]+r+@. Add the suffix
    rdZ0[][ ]ir+@. Figure out if a space is needed
    +@. Join the result
    ]ix

    @S 1_first
    @. ( number -- text )
    (1_one)x[-th]+1WD

    @>
  • operagost 2012-04-16 16:14
    Cad Delworth:
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]
    In the USA, yes, BUT:

    [UKGrammarNazi]
    In the UK, 13,387,281 rendered as words should read "thirteen million, three hundred and eighty-seven thousand, two hundred and eighty-one" (yes, including the commas).
    [/UKGrammarNazi]

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."

    The British tic of critiquing American English is one of the many reasons I loathe British people on the internet.
  • operagost 2012-04-16 16:19
    Ben Jammin:
    Cad Delworth:

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."


    One thing I dislike is improperly embedded quotation marks. Does that use different rules across the pond as well?

    By the way, "loathe" is a pretty heavy word. I'd loathe someone who shot my dog or burnt my house. Getting that angry over grammar rules that we Americans supposedly don't even know of anyways and much less follow points to other issues in the psyche.

    They do it all the time. Apparently, our short form nationality of "American" bothers them as well, since they insist on inserting the laughable "USian" designation from time to time. Everyone needs a hobby, I guess.
  • chernobyl 2012-04-16 16:38
    Methinks this code has come from beyond the Ballmer peak.
  • Stew 2012-04-16 17:01
    mschaad:
    I just appreciated the fact that the English output is still wrong.


    Cad Delworth:
    In the USA, yes ... I wish someone would have the guts to just call their variant of the language "American,"


    F:
    You clearly don't know about standard English style in writing numbers. AFAICT you are confusing it with standard American style.


    Ah yes, because clearly there's such a thing as "Standard English" as opposed to "American English". Not at all ethnocentric there.

    But kudos for seeing through the insipid facade of critiquing the code sample and spotting mschaad's clearly nationalistic agenda.

    operagost:
    Apparently, our short form nationality of "American" bothers them as well, since they insist on inserting the laughable "USian" designation from time to time.


    Good point. I suppose for maximum semantic clarity with minimum of panic-inducing nationalist saber-rattling, we should really starting using the terms "English" and "USish". Although, to avoid the appearance of disingenuity and insensitivity, I suggest we go one better and adopt "UKish" and "USish".
  • LANMind 2012-04-16 17:05
    geoffrey, MCP, PMP:
    LANMind:
    geoffrey, MCP, PMP:
    Jaunticed:
    I'm banking on this being just a joke. Evidence?

    'Shortened name of the function due to errors on polling the function

    Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.


    One of Visual Basic's many useful features is an Eval function, which executes any text string you hand to it as code. The original author is probably using Eval, and has discovered a limitation on length for the argument.


    There hasn't been an eval in VB since v6.
    Which is why this re-envisioned ".Net" pales in comparison to classic Visual Basic.


    I can tell you're trying hard to troll, but someone should smack you back into reality just the same.
  • swschrad 2012-04-16 17:13
    include (lib.universe)
    include (lib.nothought)
    include (lib.greatbooksofhistory)

    .
    .
    .
  • Jerry 2012-04-16 17:24
    Ben Jammin:
    I'd loathe someone who shot my dog or burnt my house. Getting that angry over grammar rules that we Americans supposedly don't even know of anyways and much less follow points to other issues in the psyche.
    You did that on purpose, didn't you. Doesn't matter; I'm coming to burn down your house.
  • Carl 2012-04-16 17:33
    What we have here is a simple misunderstanding of object-oriented principles. Someone told him "every function should have a this self-reference" which becomes apparent once you look at some of his other function names:

    system_will_wait_for_a_connection_request_when_you_call_this_function
    handle_initial_connection_request_with_this_function
    login_page_will_be_shown_when_control_is_passed_to_this_function
    look_up_user_id_and_password_in_database_using_perimeters_passed_to_this_function
    check_for_successful_drop_table_sql_injection_and_if_it_happened_restore_the_table_with_this_function
    ...
  • RS 2012-04-16 17:34
    Hey Nagesh is not the only one guilty of butchering the English language. I work with many WASPs and their use of the English language is not much better.
  • Jeff 2012-04-16 17:37
    Carl:
    What we have here is a simple misunderstanding of object-oriented principles.
    Makes sense. After all, this is obviously a getter:

    get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function
  • szufler 2012-04-16 17:43
    What a great project. It can only be compared to Great Pyramid in Giza.

    The manager should hire a few million Egyptian slaves. They would complete the source code with all the elseif-s.
  • szufler 2012-04-16 17:55
    MikeN:
    My favorite part is that it's version 15.1.


    Isn't it obvious? It supports numbers up to 15, right? Then it had to be AT LEAST 15 versions of this product. After all, each supported number should be carefully designed, coded and tested.

    You can't possibly expect for such a product to support, say 10 numbers in version 1.0, can you??

    CAPTCHA: transverbero
  • Darth Paul 2012-04-16 19:24
    The first .NET project I worked on made use of "temperate" variables and "temperate" tables.

    Perhaps it was the same guy?
  • Norman Diamond 2012-04-16 19:31
    '*** Product name: numbers to word enterprise edition Current version 15.1

    Others have commented on the version number but that is random. The giveaway here for the humour-impaired is the words "enterprise edition".

    THIS CODE IS IRONIC, YOU GUYS. IT WAS WRITTEN BY SOMEONE WHO HAD TO SUFFER WTFS CREATED BY COLLEAGUES, OR IMPOSED BY MANAGERS. IT'S LIKE SOME OF THE INTENTIONALLY ENTERPRISEY CODE WRITTEN IN COMMENTS ON OTHER POSTINGS, i.e. A HIGHLY SARCASTIC RESPONSE WELL EARNED BY OTHER WTFS.

    If it were a calculator it would suit the old WTF calculator contest. BY DESIGN.

    Sheesh.
  • Silverhill 2012-04-16 19:49
    Tasty:
    Bonus Spanish language oddity:
    The "hundreds" in Spanish have an irregular 500.

    cien (100)
    dos cientos (200)
    tres cientos (300)
    ...
    quinentos (500) (the first N is N+~)
    Not quite. "Five hundred" in Spanish is "quinientos". It has almost the same sound as "quiñentos" would have, but there's an extra syllable: qui-ni-en-tos.
    (Also, 200, 300, 400, 600, 700, 800, and 900 are written without a medial space: doscientos, trescientos, cuatrocientos, seiscientos, setecientos, ochocientos, novecientos.)

    [/Spanish vocabulary rant]

    ============================================

    zzo38:
    <snip>
    5:twelve-th]:twelvth
    This was written on the Twelfth of Never, right?

    ============================================

    Stew:
    I suppose for maximum semantic clarity with minimum of panic-inducing nationalist saber-rattling, we should really starting using the terms "English" and "USish".
    Nah -- just use a colloquialism from Québec: "tasunien". (Pronounced tah-zu-nee-ENH [nasal N], from the latter sounds of États Unis [United States].)
  • ozzie 2012-04-16 20:37
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]

    Also, to render numbers correctly as words (with the hyphens and everything) is a harder trick than you might think.
    Thankfully, standard English style dictates that you pretty much never spell out any numbers above nine.

    So where would you need a library like this, unless your app writes checks?


    [SpellingNazi]
    You mean cheques?
    [/SpellingNazi]

    Captcha - opto - I opto point out your spelling mistakes while you point out grammar mistakes.
  • geoffrey, MCP, PMP 2012-04-16 21:36
    LANMind:
    geoffrey, MCP, PMP:
    LANMind:
    geoffrey, MCP, PMP:
    Jaunticed:
    I'm banking on this being just a joke. Evidence?

    'Shortened name of the function due to errors on polling the function

    Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.


    One of Visual Basic's many useful features is an Eval function, which executes any text string you hand to it as code. The original author is probably using Eval, and has discovered a limitation on length for the argument.


    There hasn't been an eval in VB since v6.
    Which is why this re-envisioned ".Net" pales in comparison to classic Visual Basic.


    I can tell you're trying hard to troll, but someone should smack you back into reality just the same.


    You can't do it, you a weak bitch, you gotta keep tha PMP hand strong.
  • Not Frist 2012-04-16 21:51
    I've only seen 2 developers that write code worse than that, but amazingly most other developers I've worked with aren't that much better. Only about 10% of software developers are worth a shit, while the rest just get in the way. Pathetic.
  • Nemo 2012-04-16 23:46
    My Python version... I wrote this before I saw Gavin's post, then tweaked it a little.

    http://pastebin.com/dyeU8ykb
  • Anonymous 2012-04-17 00:12
    TGV:
    THE BUG FIXES! THE BUG FIXES!! OMG, THEY DO NOTHING!!
    The OP made me lol, but this post made me LOL. ;D

    The first WTF is VB (VB.NET?).

    The second WTF is the blatant spelling error.

    The third WTF is the ridiculous symbol names.

    The fourth WTF is assigning an error message to a 'mode' parameter... I first lost my composure here.

    The fifth WTF is the NOP when the first parameter is an empty string, and worse it checks for the condition again after it can't possibly be true!

    The sixth WTF is writing the 'mode' to the response stream.

    It keeps going and going... What's worse, some of these behaviors are evident in my colleagues' code...

    Captcha: tation - The first thing that popped into my head was "tater nation", and for that I'm sure I'm going to Hell.
  • AndyCanfield 2012-04-17 01:45
    I had to write one of these recently. Downloaded one from the Internet and translated it into PHP. Only mine had to be multi-lingual (warning - different languages parse numbers differently). Had to build in a limit of 999,999,999 because America and England can't agree on 1,000,000,000.
  • sirhegel 2012-04-17 01:50
    I'd be keen to see the German equivalent of this function.
  • Watson 2012-04-17 02:55
    AndyCanfield:
    I had to write one of these recently. Downloaded one from the Internet and translated it into PHP. Only mine had to be multi-lingual (warning - different languages parse numbers differently). Had to build in a limit of 999,999,999 because America and England can't agree on 1,000,000,000.


    I thought you said it had to be multi-lingual?
  • dkf 2012-04-17 03:02
    AndyCanfield:
    Had to build in a limit of 999,999,999 because America and England can't agree on 1,000,000,000.
    You'll be “pleased” to know that you can go further now. Usage in the UK has changed over the past couple of decades to use the US style of naming 10⁹ as “one billion”, probably due to the influence of the financial sector and the business world's close transatlantic links.

    Myself, I'd have preferred the use of the SI prefix scheme: gigaquid or terabuck.
  • Joe 2012-04-17 03:26
    This is a good demonstration of why VB and VB.NET should not exist at all. These supposedly easy-to-handle languages attract a whole lot of idiots who demand they can write code when in fact they don't even know how to turn it off and on again. C++ or C# might have stopped them in time, but they can feel right at home with Basic dialects and squeeze out something that is rather a crime than any use.
    We will sad examples like this as long as there are programming languages that pretend to be simple.
  • English Man 2012-04-17 04:46
    Self-documenting functions. Why have sqrt(x) when you could have calculate_the_square_root_of_the_number_you_want_to_get_the_square_root_of_which_is_passed_into_this_function(x)
  • Claxon 2012-04-17 04:57
    mschaad:
    I just appreciated the fact that the English output is still wrong.


    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)


    Also, to render numbers correctly as words (with the hyphens and everything) is a harder trick than you might think.
    Thankfully, standard English style dictates that you pretty much never spell out any numbers above nine.

    So where would you need a library like this, unless your app writes checks?


    I've written something like this before (by "Like this" I mean, it had a similar desired output). It was to act as a poor mans speech synthesizer. I needed audio notifications that would read out numbers, so had wav files for 0-20, one for each ten from then to 90 (20, 30, 40...) and then words like "Hundred", "Thousand", "Million" and importantly "And". Then my code would parse an integer and create a queue of which sound files to play. As I recall it took maybe 15 lines of code...

    Then again, I'd hate to see what happens when this guy discovers recursion!
  • Claxon 2012-04-17 05:03
    English Man:
    Self-documenting functions. Why have sqrt(x) when you could have calculate_the_square_root_of_the_number_you_want_to_get_the_square_root_of_which_is_passed_into_this_function(x)


    You forgot to say how it's passed to the function? Is it a perimiter? A circumference? What?!? How do you expect people to understand what your function does if you don't name it correctly!??!
  • L. 2012-04-17 05:05
    Nagesh:
    I am not seeing a problem here. It is always being recommened to use long names for better code clarification, even names of perineters and function.


    /agree . java modern style function naming inside of VB . how much worse can it get ?
  • L. 2012-04-17 05:19
    Not Frist:
    I've only seen 2 developers that write code worse than that, but amazingly most other developers I've worked with aren't that much better. Only about 10% of software developers are worth a shit, while the rest just get in the way. Pathetic.

    That's a weak point of view. imho it's closer to .001478% --
  • Musaran 2012-04-17 05:22
    As others said it is so hilariously bad it has to be a joke.

    But then, if it actually got in the codebase and stayed there, I guess the author was making a point about some WTF going on around.
  • Geoff 2012-04-17 07:05
    You know now that you say that it must be a COBOL conversion. I have seen some (automatic) COBOL to C 'compilers' that would turn the entire DATA DIVISION into one large struct or depending on how it got used elsewhere in the program a union of a few large structs. It was clear no human being evening if they had never written printf("hello world"); before would have come up with it.

    Similarly I can't imagine anyone would come up with this naming scheme for functions in BASIC unless they were working with an existing code base, perhaps (hopefully or my faith in humanity will die) automatically generated in some way.
  • Cad Delworth 2012-04-17 07:21
    Ryan:
    Problem is, this was a government facility, so the check amounts were usually pretty big numbers. And those printers that don't do lower case don't do fonts either. So before long the text wouldn't fit in the allotted space. The fix, sadly, was to print the numeric amount both in the box where it originally was, and on the "text" line.
    If these were for cheques, many machine-printed cheques here in the UK have a workaround for that.

    They use 'special' cheques which have separate pre-printed boxes for each text 'digit,' with a pre-printed 'label' above each box. So for example, 'millions,' hundred thousands,' 'ten thousands,' 'thousands,' 'hundreds,' 'tens,' 'units,' 'pence.'

    When the cheque hits the PC (or other) printer, each box has the text for zero to nine (as appropriate) printed into it. Much simpler, and avoids any grammar problems (!).
  • The_Assimilator 2012-04-17 07:22
    My favourite bit is how the example given doesn't even work with the current implementation. get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function("pass_a_number","13,387,281") would return "Exceeds word range."
  • the beholder 2012-04-17 07:48
    Watson:
    AndyCanfield:
    I had to write one of these recently. Downloaded one from the Internet and translated it into PHP. Only mine had to be multi-lingual (warning - different languages parse numbers differently). Had to build in a limit of 999,999,999 because America and England can't agree on 1,000,000,000.


    I thought you said it had to be multi-lingual?
    Yes, but haven't we established on this very thread that the bastardization of the language USians speak/write is a lot different of the way UK-born people butcher the language themselves? Might as well call them different languages altogether.
  • trollalot 2012-04-17 07:52
    Michal:
    He meant definitely "parameter" when writing "perimeter".


    Do you think?

    Michal:
    Then it starts making sense.


    Yeah... I'm not so sure anything about this code makes sense... ;o)
  • Nagesh 2012-04-17 08:13
    RS:
    Hey Nagesh is not the only one guilty of butchering the English language. I work with many WASPs and their use of the English language is not much better.

    Not understand. Wasp is insect meking nest in corner of my ofice. We are not being able to kil this leving creatures, even though I am geting stinged daily. :(
  • blank 2012-04-17 09:12
    operagost:
    Ben Jammin:
    Cad Delworth:

    The American tic of removing "and" from such phrases is one of the many reasons I loathe so-called "American (or "US") English."


    One thing I dislike is improperly embedded quotation marks. Does that use different rules across the pond as well?

    By the way, "loathe" is a pretty heavy word. I'd loathe someone who shot my dog or burnt my house. Getting that angry over grammar rules that we Americans supposedly don't even know of anyways and much less follow points to other issues in the psyche.

    They do it all the time. Apparently, our short form nationality of "American" bothers them as well, since they insist on inserting the laughable "USian" designation from time to time. Everyone needs a hobby, I guess.


    i'm a native english english speaker. i try to overlook spelling and grammatical errors in written language (unless it's a proofreading task, or something i have to sign.) communication is the aim; syntax, spelling and punctuation conventions make comprehension easier and misunderstanding less likely (in theory*)

    "USian" is twee and cliche, and sounds like someone spelling out "usen."
    if i had to use "US" instead of "American" (for example, if my audience were pedants or wierdos likely to be respond with the "2 continents" argument regardless of the context) then i'd say "US-esque", just because it sounds nicer; "USian"

    as for the OP: it's clearly been written specifically for submission to TDWTF; TRWTF is commenters who don't realise this.

    p.s. the captchas are so trivial (and repetitive) that very few robots are incapable of solving them, we should just be thankful they don't deign to comment here.

    *In theory, theory is the same as practice. In practice, it is not
  • blank 2012-04-17 09:15
    Musaran:
    As others said it is so hilariously bad it has to be a joke.

    But then, if it actually got in the codebase and stayed there, I guess the author was making a point about some WTF going on around.


    +2
  • Brad 2012-04-17 09:56
    I've been a reader for a very long time, and this is the best I've seen. I'd call fake, but it'd be very difficult to come up with something this good. Amazing, dazzling, scintillating... awe inspiring! It's so good it goes to eleevn!

    BTW (related), if anyone needs a decimal to English currency converter, I have one posted. I was surprised when I looked and couldn't find one before I wrote it.
  • Strolskon 2012-04-17 10:00
    Claxon:
    English Man:
    Self-documenting functions. Why have sqrt(x) when you could have calculate_the_square_root_of_the_number_you_want_to_get_the_square_root_of_which_is_passed_into_this_function(x)


    You forgot to say how it's passed to the function? Is it a perimiter? A circumference? What?!? How do you expect people to understand what your function does if you don't name it correctly!??!


    It calculates the parameter (2*pi) of the first perimeter. Duh.
  • Mark 2012-04-17 10:32
    geoffrey, MCP, PMP:
    Anymouse:
    C'mon. The number of VB fails is approaching the number of VB "programmers" in the world. They're hardly worth mentioning any more. Programmers need software engineers to tell them what to do, otherwise they end up writing crap. Software engineers do not allow VB in their engineered creations. Ergo, virtually all VB is crap.

    A real WTF would be any well-written VB, since that's an infinitely rarer animal.

    Captcha: minim -- the amount of education necessary to write VB.


    *sigh*

    To accept this argument, one would have to ignore the fact that Visual Basic applications have delivered more business value, in the aggregate, than all other personal computer languages combined.

    FTFY. (n.b. COBOL, most likely PL/I)
    And only because Excel contains VB (otherwise Excel would beat it).
  • Nagesh 2012-04-17 10:48
    geoffrey is plain pagal - (crazy).

    java has created more value for business. java is not restricted to just business apps, but also used inside your car, your camera, your phone, your alarm clock and everywhere you can care to think of.

    So geoffrey is failing in providing any true picture of world.
  • wonk 2012-04-17 11:04
    [quote=Article] 'Sometimes a 'four' would be outputted when '5' was passed through the perimeter[/quote]
    NOW that episode of Star Trek makes sense. Heh. 4 lights....
  • Kempeth 2012-04-17 11:07
    I like this section a lot more than the actual conversion:
    If p_mode = "" Then
    
    ' String.Replace returns the changed string which in this case is simply dropped
    ' instead of just assigning a new value you call an expensive method
    ' String.Replace throws an exception if the first parameter is an empty string.
    p_mode.Replace("", "No perimeter was passed through")
    Else
    ' NOP
    p_mode = p_mode
    End If

    ' unless you pass this delimiter in the parameter through the perimeter the if clause will never trigger
    If p_mode = "No perimeter was passed through" Then
    ' so you're essentially undoing everything you almost did in the first part...
    p_mode = ""
    Else
    ' uhm, you already did this 10 lines ago.
    ' But then again. If that code didn't do anything can you really say that you have already done it?
    If p_mode = "" Then
    p_mode.Replace("", "No perimeter was passed through")
    Else
    p_mode = p_mode
    End If
    End If

    It is strangely Zen like...
  • Nagesh 2012-04-17 11:33
    Nagesh:
    geoffrey is plain pagal - (crazy).

    java has created more value for business. java is not restricted to just business apps, but also used inside your car, your camera, your phone, your alarm clock and everywhere you can care to think of.

    So geoffrey is failing in providing any true picture of world.

    Here in Hyderabad, we use chicken for alarum clock.
  • RandomGuy 2012-04-17 11:43
    Gavin:
    Here is my quick attempt at a proper implementation of this function in Python. Note that I'm using the American method without 'and'.


    Yes, but who buys new beer if the last bottle falls down the wall?
  • A 'Brit' 2012-04-17 11:46
    The British tic of critiquing American English is one of the many reasons I loathe British people on the internet.


    The American tic of loathing the English defending their language (notice that the Scots, Welsh and Irish won't defend it); and getting confused between Britain and the coutries that make it, is one of the many reasons I loathe Armerican people on the internet.
  • the REAL geoffrey 2012-04-17 11:47
    Mark:

    FTFY. (n.b. COBOL, most likely PL/I)
    And only because Excel contains VB (otherwise Excel would beat it).


    Neither COBOL nor PL/I have provided the value of VB in aggregate. While everything may have been running one of those mainframe languages at one time, it was also at a time when total business activity was far lower than it was at the dawn of RAD platforms. Additionally, computing was a far smaller percentage of total business activity. There is a difference between greater reach and value provided.

    One could argue that VB broke ground in business computing. Being able to rapidly deploy user-friendly tools for workers' every day tasks, as well as seamless integration with Excel and Access, made Visual Basic a pioneer in the business world.
  • frits 2012-04-17 11:49
    A 'Brit':
    The British tic of critiquing American English is one of the many reasons I loathe British people on the internet.


    The American tic of loathing the English defending their language (notice that the Scots, Welsh and Irish won't defend it); and getting confused between Britain and the coutries that make it, is one of the many reasons I loathe Armerican people on the internet.

    The opinions of folks from a fallen empire which has shrunken to the size of the Philadelphia metro area do not interest me.
  • Nagesh 2012-04-17 13:07
    Nagesh fake:
    RS:
    Hey Nagesh is not the only one guilty of butchering the English language. I work with many WASPs and their use of the English language is not much better.

    Not understand. Wasp is insect meking nest in corner of my ofice. We are not being able to kil this leving creatures, even though I am geting stinged daily. :(


    WASP do not bite, faker!
  • Nagesh 2012-04-17 13:12
    Nagesh:
    Nagesh:
    geoffrey is plain pagal - (crazy).

    java has created more value for business. java is not restricted to just business apps, but also used inside your car, your camera, your phone, your alarm clock and everywhere you can care to think of.

    So geoffrey is failing in providing any true picture of world.

    Here in Hyderabad, we use chicken for alarum clock.


    You must stay in slum outside Charminar. I am in Banjara Hills, madarchod!
  • Ben Jammin 2012-04-17 13:18
    frits:
    A 'Brit':
    The British tic of critiquing American English is one of the many reasons I loathe British people on the internet.


    The American tic of loathing the English defending their language (notice that the Scots, Welsh and Irish won't defend it); and getting confused between Britain and the coutries that make it, is one of the many reasons I loathe Armerican people on the internet.

    The opinions of folks from a fallen empire which has shrunken to the size of the Philadelphia metro area do not interest me.


    Language is meant to communicate ideas. If those on the receiving end can interpret the original idea, then success.

    "From Cambridge University .

    Olny srmat poelpe can raed tihs.
    I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, t he olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Amzanig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!"

    (What is scary is that my spell check only catches 3 words out of that mess.)
  • Nagesh 2012-04-17 13:33
    That mail in circulate since birth of internet. Tim Berner Lee write it!
  • Tim Berner Lee 2012-04-17 13:43
    Nagesh is right, I did.

    Captcha: nimis. My nimis Tim Berner Lee, I help Dan Quail invent the Internet, please to meet you.
  • Real Tim Berner Lee 2012-04-17 13:47
    FAKER Tim Berner Lee:
    Nagesh is right, I did.

    Captcha: nimis. My nimis Tim Berner Lee, I help Dan Quail invent the Internet, please to meet you.

    Faker!!
  • Strolskon 2012-04-17 13:47
    Ben Jammin:

    Olny srmat poelpe can raed tihs.

    OMG THIS IS SO TRUE I OLWAYS NEW I WAS SMARTER THEN MY FRIENDS (lol i can read it i bet noone else can)).

    Ben Jammin:
    The phaonmneal pweor of the hmuan mnid

    How is identifying a rearranged set of letters "phaonmneal pweor"? I bet Babbage's analytical engine would have managed to do that.


    Sorry for the rant. Oh wait, this is TheDailyWTF, I don't have to apologize.
  • Jeff 2012-04-17 13:55
    Strolskon:
    Ben Jammin:

    Olny srmat poelpe can raed tihs.

    OMG THIS IS SO TRUE I OLWAYS NEW I WAS SMARTER THEN MY FRIENDS (lol i can read it i bet noone else can)).
    I can read it, but only because I've read it before, so I already know what it says.
  • Nagesh 2012-04-17 14:00
    Nagesh:
    Nagesh:
    Nagesh:
    geoffrey is plain pagal - (crazy).

    java has created more value for business. java is not restricted to just business apps, but also used inside your car, your camera, your phone, your alarm clock and everywhere you can care to think of.

    So geoffrey is failing in providing any true picture of world.

    Here in Hyderabad, we use chicken for alarum clock.


    You must stay in slum outside Charminar. I am in Banjara Hills, madarchod!

    All India is slum, excepting Goa. Do not believing what you see on TV.
  • Nagesh 2012-04-17 14:15
    Real Tim Berner Lee:
    FAKER Tim Berner Lee:
    Nagesh is right, I did.

    Captcha: nimis. My nimis Tim Berner Lee, I help Dan Quail invent the Internet, please to meet you.

    Faker!!


    You are equal fake.

    Real Tim Berner Lee is not having time to post here, madarchod!
  • Tud 2012-04-17 14:18
    Fake Nagesh:
    Nagesh:
    Fake Nagesh:
    Nagesh:
    geoffrey is plain pagal - (crazy).

    java has created more value for business. java is not restricted to just business apps, but also used inside your car, your camera, your phone, your alarm clock and everywhere you can care to think of.

    So geoffrey is failing in providing any true picture of world.

    Here in Hyderabad, we use chicken for alarum clock.


    You must stay in slum outside Charminar. I am in Banjara Hills, madarchod!

    All India is slum, excepting Goa. Do not believing what you see on TV.


    Don't insult India Faker! And learn speaking English better! Do not is shorter and more compatible to say Don't.
  • Tud 2012-04-17 14:19
    Now that was a real fail.
  • Remy Martin 2012-04-17 14:19
    I'm sorry to announce that I have some bad news. You've probably already guessed since there was no article today, but Alex unexpectedly passed. This is especially hard on his widow, who is now forced to due both their taxes on her own to avoid an IRS penalty. Please keep her in your prayers.
  • Zunetang 2012-04-17 14:51
    Remy Martin:
    I'm pleased to announce that I have some wonderful news. You've probably already guessed since there wasn't another tired, shitty article today, but Alex finally dropped dead. This is especially great news for his windows, which will no longer have to reflect his ugly face. Even the IRS doesn't missing out on his income taxes - the world is such a better place now. Please keep praying for him to wind up in hell. I, for one, am hoping he will suck Satan's cock for all eternity.
    Ding! Dong! - The faggot's dead!
    (Which old fag?)
    The Grecian fag!
    Ding, dong, the Grecian faggot's dead!

    Lot's 'a love, fuck face!!!
  • the 2012-04-17 15:19
    Remy Martin:
    I'm sorry to announce that I have some bad news. You've probably already guessed since there was no article today, but Alex unexpectedly passed. This is especially hard on his widow, who is now forced to due both their taxes on her own to avoid an IRS penalty. Please keep her in your prayers.


    You must be new here. Alex frequently posts a lame wtf and then skips a day just to piss people off.
  • AGray 2012-04-17 15:34
    Best rewritten:


    If String.IsNullOrEmpty(p_mode) Then
    p_mode = "No parameter was passed through."
    End If


    The value of KISS is not lost on me. The engineering principle is pretty good, too.
  • AGray 2012-04-17 15:34
    Best rewritten:


    If String.IsNullOrEmpty(p_mode) Then
    p_mode = "No parameter was passed through."
    End If


    The value of KISS is not lost on me. The engineering principle is pretty good, too.
  • AGray 2012-04-17 15:37
    Better still:

    If String.IsNullOrEmpty(p_mode) Then
    Throw New ArgumentNullException("p_mode")
    End If
  • Ben Jammin 2012-04-17 15:37
    the:
    Remy Martin:
    I'm sorry to announce that I have some bad news. You've probably already guessed since there was no article today, but Alex unexpectedly passed. This is especially hard on his widow, who is now forced to due both their taxes on her own to avoid an IRS penalty. Please keep her in your prayers.


    You must be new here. Alex frequently posts a lame wtf and then skips a day just to piss people off.


    You must be new here. When Alex skips a day to piss people off, Remy notifies us that Alex has passed.

    P.S. When my Captcha is filled out by my browser's auto form filler... it is probably ineffective.
  • Saxton! 2012-04-17 15:44
    Zunetang:
    Remy Martin:
    I'm pleased to announce that I have some wonderful news. You've probably already guessed since there wasn't another tired, shitty article today, but Alex finally dropped dead. This is especially great news for his windows, which will no longer have to reflect his ugly face. Even the IRS doesn't missing out on his income taxes - the world is such a better place now. Please keep praying for him to wind up in hell. I, for one, am hoping he will suck Satan's cock for all eternity.
    Ding! Dong! - The faggot's dead!
    (Which old fag?)
    The Grecian fag!
    Ding, dong, the Grecian faggot's dead!

    Lot's 'a love, fuck face!!!


    Dude, relax.
  • the beholder 2012-04-17 15:57
    Remy Martin:
    I'm sorry to announce that I have some bad news. You've probably already guessed since there was no article today, but Alex unexpectedly passed. This is especially hard on his widow, who is now forced to due both their taxes on her own to avoid an IRS penalty. Please keep her in your prayers.
    Oh we're not worried. You already said he died a few days ago, and then in the next day he got better.
  • Impatient Captcha wizard 2012-04-17 16:05
    Ben Jammin:
    the:
    Remy Martin:
    I'm sorry to announce that I have some bad news. You've probably already guessed since there was no article today, but Alex unexpectedly passed. This is especially hard on his widow, who is now forced to due both their taxes on her own to avoid an IRS penalty. Please keep her in your prayers.


    You must be new here. Alex frequently posts a lame wtf and then skips a day just to piss people off.


    You must be new here. When Alex skips a day to piss people off, Remy notifies us that Alex has passed.

    P.S. When my Captcha is filled out by my browser's auto form filler... it is probably ineffective.

    Doesn't matter. The captcha is just a minor deterrence. What actually prevents users from posting is Akismet.

    acsi
    aliquam
    amet
    aptent
    bene
    consequat
    cogo
    eros
    facilisis
    genitus
    gravis
    haero
    nimis
    mara
    oppeto
    opto
    paratus
    pecus
    populus
    plaga
    praesent
    quis
    saepius
    saluto
    tation
    tristique
    valetudo
    validus
    vereor
    verto
    vindico

    PS: I like the fact that when you hit "Preview" it generates a different one with the same word.
  • Real Advertiser 2012-04-17 16:31
    If I was paying a newspaper to run my ads and they decided to put out an issue whenever they darn well felt like it, I'd immediately pull my ads and sue them for damages.
  • DirkAndTheMac 2012-04-17 16:45
    The bugs fixed were hysterical, the icing on a very splendid cake.... Somehow managed to misspell 'three' in the first iteration and whilst fixing that failed to notice that 5 would be 'four'..... Later on he even admits to having to shorten the name of the function from it's now concise name!!
  • Silverhill 2012-04-17 19:18
    Real Advertiser:
    If I was paying a newspaper to run my ads and they decided to put out an issue whenever they darn well felt like it, I'd immediately pull my ads and sue them for damages.
    BFD. You're not paying Alex anything for his freely-provided work, and you think you have a right to complain? Grow up, weenie.
  • Friedrice The great 2012-04-17 22:02
    RS:
    Hey Nagesh is not the only one guilty of butchering the English language. I work with many WASPs and their use of the English language is not much better.


    Weird Anti-Social Perverts?
  • frits 2012-04-17 22:22
    Friedrice The great:
    RS:
    Hey Nagesh is not the only one guilty of butchering the English language. I work with many WASPs and their use of the English language is not much better.


    Weird Anti-Social Perverts?
    I thought he was referring to a bunch of Blackie Lawlesses.
  • da Doctah 2012-04-17 22:52
    Nagesh:
    Nagesh fake:
    Not understand. Wasp is insect meking nest in corner of my ofice. We are not being able to kil this leving creatures, even though I am geting stinged daily. :(


    WASP do not bite, faker!


    Sting != bite, fakir!
  • omfg 2012-04-17 22:59
    >13-19 becomes easy (nine) + (teen)

    threeteen
    fiveteen
    eightteen

    still better than "five" randomly printed for 4, though
  • North Shore Beach Bum 2012-04-18 01:46
    In Hawai`i, we pronounce "3" the same as tree and rarely use plurals.

    Numbah tree day of Christmas, my tutu gave to me:
    tree dry squid,
    two coconut,
    and one myna bird in one papaya tree!
  • oheso 2012-04-18 04:52
    Cad Delworth:
    For example, try asking for a "fanny pack" in a shop in England and see what you get (possibly including being thrown out of the shop!).


    Depending, of course, on the sort of shop!
  • oheso 2012-04-18 04:57
    ¯\(°_o)/¯ I DUNNO LOL:
    Yeah, I remember ol' HX_373. He was THX_1138's granddad, ya know. And when he got to drinking, he would get as pissed as a parameter!


    <3
  • null 2012-04-18 06:12
    Remy Martin:
    I'm sorry to announce that I have some bad news. You've probably already guessed since there was no article today, but Alex unexpectedly passed.


    Was a he passed as a perimeter?
    if (todaysWtf == null)
    return "No Alex was passed.";

    Captcha 'incassum' -- they should keep a couple of spare Wtf's laying around incassum Alex doesn't feel like posting on a given day.

  • Real Advertiser 2012-04-18 08:06
    Silverhill:
    Real Advertiser:
    If I was paying a newspaper to run my ads and they decided to put out an issue whenever they darn well felt like it, I'd immediately pull my ads and sue them for damages.
    BFD. You're not paying Alex anything for his freely-provided work, and you think you have a right to complain? Grow up, weenie.


    Oh...you must have the ads on the side blocked then.

    How does your foot taste?
  • TheSHEEEP 2012-04-18 10:30
    Are you people nuts?

    "Tokyo & Beijing - see you at QCon (April 16-20) "

    I'm pretty sure this has SOMETHING to do with the absence of new articles...
  • erat 2012-04-18 10:36
    Tasty:
    KattMan:
    Honestly it's a language parser, should be easy to do all numbers with little more code.

    Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
    After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

    Yeah this function is a serious WTF, even in its name, sounds like the forgot to name it and just put the comment as the name.


    Never depend on logic when using natural languages!

    Your 13-19 range doesn't quite work. For example:

    three+teen != "thirteen"
    five+teen != "fifteen"

    Bonus Spanish language oddity:
    The "hundreds" in Spanish have an irregular 500.

    cien (100)
    dos cientos (200)
    tres cientos (300)
    ...
    quinentos (500) (the first N is N+~)


    Just for your information: 700 (setecientos / siete cientos) and 900 (novecientos / nueve cientos) are also irregular... just saying.
  • daveime 2012-04-18 10:37
    There's so many WTFs I don't know where to start.


    '***************************** Example Usage**********************************************

    ' WORD_CONVERTED_FROM_A_NUMBER_PASSED_THROUGH_A_PERIMETER("pass_a_number","13,387,281")
    '
    ' would return: thirteen million three hundred and eighty seven thousand two hundred and eighty one


    Except it only works for numbers up to 15, including "eleevn" and "forteen".

    I think I discovered why it's version 15.1 ... that's the range of numbers it actually works for !

    Future plans ... after the first 1000 it's going to get easier, so we can start using exponential upgrades ! Although memory is going to get a bit tight by 100 million, as it will take around 7GB just to store the code.
  • depressed cheescake 2012-04-18 11:35
    Real Advertiser:
    Silverhill:
    Real Advertiser:
    If I was paying a newspaper to run my ads and they decided to put out an issue whenever they darn well felt like it, I'd immediately pull my ads and sue them for damages.
    BFD. You're not paying Alex anything for his freely-provided work, and you think you have a right to complain? Grow up, weenie.


    Oh...you must have the ads on the side blocked then.

    How does your foot taste?


    Presumably you mean the Buildmaster ads from Inedo, you know the company Alex works for? Guess they're probably not too bothered.

    More to the point why do *you* give a shit about whether advertising revenue is well spent on this site?

  • bad_management 2012-04-18 11:51
    Perimeter, parameter.
    Toe-may-toe, toe-mah-toe.
    Poe-tay-toe, poe-tah-toe.
  • Orwellian_Startrek 2012-04-18 12:52
    [quote user="wonk"][quote=Article] 'Sometimes a 'four' would be outputted when '5' was passed through the perimeter[/quote]
    NOW that episode of Star Trek makes sense. Heh. 4 lights....[/quote]

    Lights? Star Trek?

    You realize that that episode was a ripoff from 1984, right? (4 fingers)
  • Jay 2012-04-18 12:58
    no:
    Bleat:
    'API call removed due to high demand

    1) How much was this used that this was ever in 'high demand'


    Well, it never was defined what kind of 'high demand' - as in 'all his colleagues demanded that his hands be separated from his arms before being allowed near a computer again'


    Or, The only time people demand this function is when they are high on something.
  • Jay 2012-04-18 13:07
    ozzie:
    mschaad:
    I just appreciated the fact that the English output is still wrong.

    [GrammarNazi]
    13,387,281 rendered as words should read
    "thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
    [/GrammarNazi]

    Also, to render numbers correctly as words (with the hyphens and everything) is a harder trick than you might think.
    Thankfully, standard English style dictates that you pretty much never spell out any numbers above nine.

    So where would you need a library like this, unless your app writes checks?


    [SpellingNazi]
    You mean cheques?
    [/SpellingNazi]

    Captcha - opto - I opto point out your spelling mistakes while you point out grammar mistakes.


    Umm, maybe because he has an app that prints checks?

    RE SpellingNazi: No, that should be UKEnglishNazi. In real modern English, you know, US English, we spell it "checks".
  • Jay 2012-04-18 13:11
    Ben Jammin:
    frits:
    A 'Brit':
    The British tic of critiquing American English is one of the many reasons I loathe British people on the internet.


    The American tic of loathing the English defending their language (notice that the Scots, Welsh and Irish won't defend it); and getting confused between Britain and the coutries that make it, is one of the many reasons I loathe Armerican people on the internet.

    The opinions of folks from a fallen empire which has shrunken to the size of the Philadelphia metro area do not interest me.


    Language is meant to communicate ideas. If those on the receiving end can interpret the original idea, then success.

    "From Cambridge University .

    Olny srmat poelpe can raed tihs.
    I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, t he olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Amzanig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!"

    (What is scary is that my spell check only catches 3 words out of that mess.)


    We do, however, give bonus points for making text easy to understand. If I write, "I went to the store", you can very quickly discern my meaning. If I write, "i wnet ot het tsoer", you may be able to figure it out, but it takes considerably longer. Likewise if I write, "I perambulated to the retail establishment", or any of other numerous senseless added obfuscations, you have to think for an extra second or two. My time is too valuable to waste on people who cannot express their thoughts clearly.
  • HotelBravoMike 2012-04-18 15:30
    Well, I took a shot at it:

    + my version can do German and English
    + the range is bigger than just 0 to 15
    + I spell 'eleven' (or 'Elf') correctly

    - use of global variables not really ideal
    - limited range (-2*10e9 to +2*10e9)

    I actually thought this was necessary due to a 32bit machine - however with TCL (everything is a string) this is not really a restriction. As long as I do not calculate with the so called integers. ;)

    I am not sure if the created german words are to be concatenated or separate. (Embarrasingly for native speake, I know.)

    For Example:
    the number 1,403,211
    Eine Million Vierhundertdrei Tausend Zweihundertelf
    ... does not look right to me
    Einemillionvierhundertdreitausendzweihundertelf
    ... is not really very readable

    I decide to present the version which is more readable.

    If someone could give an educated opinion on that please.....

    So, code works in 2 parts:

    a) setup

    setup de
    or
    setup en

    ... declares 2 global varables called 'language' and 'numbers'

    b) conversion

    set text_representation [int2txt decimal_representation]
    e.g.
    puts [int2txt 123456789]
    -->
    onehundredtwentythree million, fourhundredfiftysix thousand, sevenhundredeightynine
    or
    Einhundertdreiundzwanzig Millionen Vierhundertsechsundfünfzig Tausend Siebenhundertneunundachtzig



    ## #
    ## # setup a language
    ## #

    proc setup {la} {
    global language numbers
    set language $la
    # remove existing configuration to prevent contamination
    if {[info exists numbers]} {unset numbers}
    # select from list of supported languages
    switch -exact -- $la {
    en {
    set numbers(0) zero
    set numbers(1to9) [list one two three four five six seven eight nine]
    set numbers(10to19) [list ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen]
    set numbers(20to90) [list twenty thirty fourty fifty sixty seventy eighty ninety]
    set numbers(100) hundred
    set numbers(pow3) [list thousand million billion]
    set numbers(neg) minus
    set numbers(ovr) "over two billion"
    set numbers(undr) "less than minus two billion"
    # 3 digit partitioning, example: one million <AND> twohundred thousand <AND> twelve
    #set numbers(and) "and "
    set numbers(and) "\b, "
    #set numbers(and) ""
    }
    de {
    set numbers(0) Null
    set numbers(1) Eins
    set numbers(1to19) [list ein zwei drei vier fünf sechs sieben acht neun zehn \
    elf zwölf dreizehn vierzehn fünfzehn sechzehn siebzehn achtzehn neunzehn]
    set numbers(20to90) [list zwanzig dreisig vierzig fünfzig sechzig siebzig achtzig neunzig]
    set numbers(100) hundert
    set numbers(pow3.0) [list tausend million milliarde]
    set numbers(pow3.1) [list tausend millionen milliarden]
    set numbers(pow3.ending) [list s {} e e]
    set numbers(neg) Minus
    set numbers(ovr) "Über Zwei Milliarden"
    set numbers(undr) "Weniger als Minus Zwei Milliarden"
    }
    default {
    puts stderr "'$la' is not a supported language - please choose 'en' or 'de' - exiting."
    exit 1
    }
    }
    set numbers(upper) [expr (1 << 31) - 1]
    set numbers(lower) [expr (1 << 31)]
    }

    ## #
    ## # translate integer to text
    ## #

    # Note: in TCL everything is a string, so no explicit format %d conversion

    # integer into segments of 3 digits, empty string if segment is '000'
    proc to3digits {i} {
    set l [list ]
    set le [string length $i]
    # split into set of 3 digits each
    set n -1
    for {set p1 [expr $le-3]; set p2 [expr $le-1]} {$p2 >= 0} {incr p1 -3; incr p2 -3} {
    set s [string range $i $p1 $p2]
    regsub {^0+} $s "" s
    incr n; set di($n) $s
    }
    # reverse list
    for {} {$n >= 0} {incr n -1} {
    lappend l $di($n)
    }
    return $l
    }

    # german locale (de)
    proc 3digits2txt.de {d} {
    global numbers
    set s ""
    if {$d >= 100} {
    set hundreds [expr ($d/100)]
    set s [lindex $numbers(1to19) [expr $hundreds-1]]
    append s $numbers(100)
    set d [expr $d % 100]
    }
    if {$d == 0} {return $s}
    if {$d < 20} {
    append s [lindex $numbers(1to19) [expr ($d%20)-1]]
    } else {
    set tens [expr $d/10]
    set ones [expr $d%10]
    if {$ones > 0} {
    append s [lindex $numbers(1to19) [expr $ones-1]]
    append s und
    }
    append s [lindex $numbers(20to90) [expr $tens-2]]
    }
    return $s
    }
    proc int2txt.de {i} {
    global language numbers
    if {$i == 1} {return $numbers(1); return}
    set di [to3digits $i]
    set pow [llength $di]
    incr pow -1
    set txt ""
    foreach d $di {
    incr pow -1
    if {$d == {}} {continue}
    set s [3digits2txt.de $d]
    set plural 1
    if {[expr $d%100] == 1} {
    set plural 0
    append s [lindex $numbers(pow3.ending) [expr $pow+1]]
    }
    if {$pow >= 0} {
    append txt [format "%s %s " [string totitle $s] [string totitle [lindex $numbers(pow3.$plural) $pow]]]
    } else {
    append txt [format "%s " [string totitle $s]]
    }
    }
    return $txt
    }
    # english locale (en)
    proc 3digits2txt.en {d} {
    global numbers
    set s ""
    if {$d >= 100} {
    set hundreds [expr ($d/100)]
    set s [lindex $numbers(1to9) [expr $hundreds-1]]
    append s $numbers(100)
    set d [expr $d % 100]
    }
    if {$d == 0} {return $s}
    if {$d < 20} {
    if {$d < 10} {
    append s [lindex $numbers(1to9) [expr ($d%10)-1]]
    } else {
    append s [lindex $numbers(10to19) [expr ($d%20)-10]]
    }
    } else {
    append s [lindex $numbers(20to90) [expr ($d/10)-2]]
    append s [lindex $numbers(1to9) [expr ($d%10)-1]]
    }
    return $s
    }

    proc int2txt.en {i} {
    global numbers
    set di [to3digits $i]
    set pow [llength $di]
    incr pow -1
    set and ""
    set txt ""
    foreach d $di {
    incr pow -1
    if {$d == {}} {continue}
    set s [3digits2txt.en $d]
    if {$pow >= 0} {
    append txt [format "%s%s %s " $and $s [lindex $numbers(pow3) $pow]]
    } else {
    append txt [format "%s%s " $and $s]
    }
    set and $numbers(and)
    }
    return $txt
    }

    # main converter (calls locale)

    proc int2txt {i} {
    global language numbers
    if {$i == 0} {puts -nonewline $numbers(0); return}
    if {$i < $numbers(lower)} {puts -nonewline $numbers(undr); return}
    if {$i > $numbers(upper)} {puts -nonewline $numbers(ovr); return}
    if {$i < 0} {
    set i [expr abs($i)]
    puts -nonewline [format "%s " $numbers(neg)]
    }
    int2txt.$language $i
    }



    Looks OK in preview so lets submit. ;)
  • HotelBravoMike 2012-04-18 15:54
    Arghhh.. what a right mess-up on the main converter call.
    (The initial version printed directly to console instead of returning the string.)

    This should do the trick


    # main converter (calls locale)

    proc int2txt {i} {
    global language numbers
    if {$i == 0} {return $numbers(0)}
    if {$i < $numbers(lower)} {return $numbers(undr)}
    if {$i > $numbers(upper)} {return $numbers(ovr)}
    if {$i < 0} {
    set i [expr abs($i)]
    return [format "%s %s" $numbers(neg) [int2txt.$language $i]]
    }
    return [int2txt.$language $i]
    }
  • Dutchie 2012-04-18 16:17
    Over at stackoverflow.com there are some nice solutions like this one.
  • Nemo 2012-04-18 16:38
    I found my earlier version had some float/int problems with larger numbers, and I was taking the wrong field for the overall limit. So, version 2:

    http://pastebin.com/xq66a3H3
  • NRC 2012-04-18 17:07
    Looks like a novice programmer struggling with immutable strings. I wonder how many hours were spent trying to figure out why p_mode.Replace() did not actually replace the characters in that instance, before giving up (but still leaving the pointless code in there).
  • zzo38 2012-04-18 17:28
    Silverhill:

    zzo38:
    <snip>
    5:twelve-th]:twelvth
    This was written on the Twelfth of Never, right?
    Oops! Thanks for notifying me this mistake, I will fix it
  • Acacio 2012-04-18 17:53
    Wow, just wow. I've read a lot of stupid stuff in the DWTF but this one is just ... wow.
    In so many dimensions....

    We can close DWTF: after this one, all the rest will paleas watered down beer.
  • Silverhill 2012-04-18 19:55
    Real Advertiser:
    Silverhill:
    Real Advertiser:
    If I was paying a newspaper to run my ads and they decided to put out an issue whenever they darn well felt like it, I'd immediately pull my ads and sue them for damages.
    BFD. You're not paying Alex anything for his freely-provided work, and you think you have a right to complain? Grow up, weenie.
    Oh...you must have the ads on the side blocked then.

    How does your foot taste?
    No, I don't have the ads on the side blocked; I just don't let them bother me. (Some of them are even interesting, BTW, and I've looked at what they offer.)

    Feel free to report on the taste of your foot, instead.

    (As depressed cheescake asked, "[W]hy do *you* give a shit about whether advertising revenue is well spent on this site?")




    Addendum (2012-04-19 17:34):
    (Also, note that the adas are served to the browser even if the main content has not been updated. The advertisers still get the agreed-on number of displays, as long as people at least check to see if the site has updated.)

    Addendum (2012-04-19 17:34):
    s/adas/ads/
  • someone else 2012-04-21 17:30
    Darth Paul:
    The first .NET project I worked on made use of "temperate" variables and "temperate" tables.

    Perhaps it was the same guy?


    Variables and look-up tables are premature optimizations. Real programmers use functions for everything. And "temperate" "functions" sort-of exists:
    http://en.wikipedia.org/wiki/Distribution_%28mathematics%29#Tempered_distributions_and_Fourier_transform
  • Alexis 2012-04-23 08:11
    The developer who wrote this function opted for the solution requiring absolutely no thought whatsoever. It's actually infuriating to see something this lazy.
  • beefiron 2012-04-23 08:46
    Not to mention threeteen
  • A. Nonymous Coward 2012-05-15 15:54
    ' would return: thirteen million three hundred and eighty seven thousand two hundred and eighty one.


    TRWTF is that when writing numbers out like this, an 'and' signifies a decimal point.
  • lol dalmations 2012-06-20 14:57
    I've seen "One Hundred and One Dalmations".
    I've seen en_US sentence punctuation inside a quotation.
    so,
    Is it known in the US as "One Hundred One Dalmations"?
    Is it known in the US as "One Hundred One Dalmations?".
  • streaky 2012-07-20 14:44
    This guy clearly studied at Gnome University's School of Annoying to Write Code.