• (cs)

    ot*"0.Frist"

    Good thing is that even discount percentages like 1000% wouldn't make the final price negative...

  • Nobody (unregistered)

    Lame

    Additional text to avoid spam filter

  • (cs) in reply to alo
    alo:
    Am I frist this time?
    Yeah, but you didn't get the joke. You should have made a long comment....
  • (cs) in reply to ochrist

    The "frist" strategy is to be logged in, writing a comment as fast as you can and the edit it later to something less embarrasing.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)

    TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

    VB? How am I not surprised? (It was either that or PHP.)

  • alvatrus (unregistered) in reply to alo

    Which makes every poster of any top comment a loser by default.

  • (cs)

    The person who wrote that had the right buzzwords on their CV - they'd played with the right toys.

    And they probably had nice personalities as well and came across well at their interviews.

    Of course using string conversion is a total WTF. That the code also doesn't work actually gives him grounds to change it, so perhaps better than if it were written correctly.

    The code appears to not work because they forget that you need 2 digits to represent the percent so it is giving a discount of 0.5 when it should be 0.05?

  • AGray (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

    VB? How am I not surprised? (It was either that or PHP.)

    I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

  • b_russel (unregistered)

    I wonder what would have happened if the original programmer would have fixed this bug: Would he have added a few PadLeft and IndexOf calls, and a regular expression or two for good measure? ;-)

  • the beholder (unregistered) in reply to Cbuttius
    Cbuttius:
    The person who wrote that had the right buzzwords on their CV - they'd played with the right toys.

    And they probably had nice personalities as well and came across well at their interviews.

    Of course using string conversion is a total WTF. That the code also doesn't work actually gives him grounds to change it, so perhaps better than if it were written correctly.

    The code appears to not work because they forget that you need 2 digits to represent the percent so it is giving a discount of 0.5 when it should be 0.05?

    Ooookay... that is what is missing. I wasn't sure what was the bug until I read your post.

    Yes people, the code is awful, but it at least is written in a way that's supposed to calculate the right amount (except when it fits Cbuttius' example). If you feed it a 10% discount or higher it will perform correctly.

    It's the stupider, bug-prone route to the right place.

  • Foo Bar (unregistered) in reply to AGray
    AGray:
    I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.
    Possibly because some Peters rise up to their level of incompetence by way of: use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.
  • Peter Bouillon (unregistered)

    Yes, of course this code is to blame.

    • If O.DiscountPercentage is lower than 10, then the calculated discount will off by a factor of 10.

    • If O.DiscountPercentage contains a decimal point (e.g. "10.5"), the digits behind it will be lost.

    • If O.DiscountPercentage is negative, then "0." & Convert.ToInt32(O.DiscountPercentage) will result in nonsense.

  • Peter Bouillon (unregistered) in reply to the beholder
    the beholder:
    If you feed it a 10% discount or higher it will perform correctly.

    It won't work with a 100% discount.

  • very punny (unregistered)

    [quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this.

  • TheSHEEEP (unregistered) in reply to Foo Bar
    Foo Bar:
    AGray:
    I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.
    Possibly because some Peters rise up to their level of incompetence by way of: use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.

    Also, it is (or was, rather, guess today it is JavaScript) used in many schools for computer science lessons.

  • Pokepoke (unregistered)

    This sounds like a beginning of a journey... Cant wait for chapter 2 to come!

  • RRDY (unregistered)

    But dividing by 100 is HARD!

    captcha: nobis, as in this person had nobis getting anywhere near a computer.

  • Herwig (unregistered) in reply to Foo Bar
    Foo Bar:
    AGray:
    I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.
    Possibly because some Peters rise up to their level of incompetence by way of: use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.
    ...and then they are talking about the "Storage Procedures" they've written in "Virtual Basic" and their other programming skills in in HTML or FTP...
  • Valetudo (unregistered) in reply to Herwig
    Herwig:
    Foo Bar:
    AGray:
    I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.
    Possibly because some Peters rise up to their level of incompetence by way of: use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.
    ...and then they are talking about the "Storage Procedures" they've written in "Virtual Basic" and their other programming skills in in HTML or FTP...

    In the final stages, they talk about writing a gui in VB to trace an IP.

  • Someone (unregistered)

    Just back from the trauma center, no further comments.

  • (cs) in reply to Peter Bouillon
    Peter Bouillon:
    the beholder:
    If you feed it a 10% discount or higher it will perform correctly.

    It won't work with a 100% discount.

    Or any percentage with a decimal, like 33.33%

  • (cs) in reply to RRDY
    RRDY:
    But dividing by 100 is HARD!

    captcha: nobis, as in this person had nobis getting anywhere near a computer.

    Inefficient, too.

    Had a teacher one time that assigned us to minimize parenthesis in something like this:

     A + ((B * C) * (D * E)) / ((F * G) * H)

    My response:

     A + B * C * D * E / F / G / H

    Whereupon he objected lamely that division was inefficient...but he gave in when I pointed out that the whole objective of the problem was to get rid of parenthesis.

  • Spudley (unregistered) in reply to very punny

    [quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this. [/quote]

    This int what I was expecting. I object that they string me along just for a punchline like that! I'll have to double my efforts to come up with a suitable array of ripostes.

  • (cs)
    One thing was for certain - this was going to be a long/*Get it? Long...Decimal... When was the last time you saw a data type pun?*/ week.

    It's been a Short while.

  • (cs) in reply to very punny

    [quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this. [/quote]

    I would string up the developer who did this

  • (cs) in reply to chubertdev

    How is it that no one had noticed a problem with discounts less than 10% for so long?

  • lunaryorn (unregistered) in reply to D-Coder
    D-Coder:
    How is it that no one had noticed a problem with discounts less than 10% for so long?
    It seems to be a very generous company... which might explain the quality of the code: There seems to be not enough money left to replace the Office expert dabbling on programming with a real, appropriately paid developer.
  • Oscar (unregistered) in reply to D-Coder
    D-Coder:
    How is it that no one had noticed a problem with discounts less than 10% for so long?
    Maybe it is one of those shady businesses that marks everything down 40% or more routinely.

    Scam alert #1, for you naive youngsters, just in time for the holidays: jewelry stores price their $1000 rings at $2000 then give you "50% off", so you can impress your girlfriend how much you're (not really) spending on her. The problem is, she's much more tuned in to jewelry prices than you are, having spent 20 years now obsessing on the topic. So you're really not fooling her.

    Scam alert #2: once you do buy that ring, and complete the related ceremonies, you can start counting down on one hand how many more times in your life you're going to get laid by a hot chick instead of a grudging grump.

  • (cs) in reply to Peter Bouillon
    Peter Bouillon:
    Yes, of course this code is to blame.
    • If O.DiscountPercentage is lower than 10, then the calculated discount will off by a factor of 10.

    • If O.DiscountPercentage contains a decimal point (e.g. "10.5"), the digits behind it will be lost.

    • If O.DiscountPercentage is negative, then "0." & Convert.ToInt32(O.DiscountPercentage) will result in nonsense.

    And if O.DiscountPercentage is 100 or greater, the calculated discount will be too small.

  • Kae (unregistered) in reply to very punny

    Someone's going to pull some double shifts. It's going to get a bit hectic. But stuff like that builds character. It shows class. Nothing to object to.

  • The Big Picture Thinker (unregistered) in reply to TheSHEEEP
    TheSHEEEP:
    Foo Bar:
    AGray:
    I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.
    Possibly because some Peters rise up to their level of incompetence by way of: use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.

    Also, it is (or was, rather, guess today it is JavaScript) used in many schools for computer science lessons.

    Or Java or C#, which is essentially VB with curly brackets

  • (cs) in reply to The Big Picture Thinker
    The Big Picture Thinker:
    Or Java or C#, which is essentially VB with curly brackets

    And case sensitivity. Which is the biggest WTF in any programming language.

  • C-Derb (unregistered) in reply to da Doctah
    da Doctah:
    Peter Bouillon:
    Yes, of course this code is to blame.
    • If O.DiscountPercentage is lower than 10, then the calculated discount will off by a factor of 10.

    • If O.DiscountPercentage contains a decimal point (e.g. "10.5"), the digits behind it will be lost.

    • If O.DiscountPercentage is negative, then "0." & Convert.ToInt32(O.DiscountPercentage) will result in nonsense.

    And if O.DiscountPercentage is 100 or greater, the calculated discount will be too small.

    A discount > 100% would be paying someone to take your products off your hands. At that point, you've got bigger problems than string arithmetic.

  • eek (unregistered) in reply to very punny

    [quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this. [/quote]

    Your String of data type puns disgusts me.

  • Tasty (unregistered) in reply to Coyne
    Coyne:
    RRDY:
    But dividing by 100 is HARD!

    captcha: nobis, as in this person had nobis getting anywhere near a computer.

    Inefficient, too.

    Had a teacher one time that assigned us to minimize parenthesis in something like this:

     A + ((B * C) * (D * E)) / ((F * G) * H)

    My response:

     A + B * C * D * E / F / G / H

    Whereupon he objected lamely that division was inefficient...but he gave in when I pointed out that the whole objective of the problem was to get rid of parenthesis.

    I imagine a modern compiler's optimizer will reduce your code to something more efficient. It's not your father's Fortran anymore.

  • foo (unregistered) in reply to Coyne
    Coyne:
    RRDY:
    But dividing by 100 is HARD!

    captcha: nobis, as in this person had nobis getting anywhere near a computer.

    Inefficient, too.

    Had a teacher one time that assigned us to minimize parenthesis in something like this:

     A + ((B * C) * (D * E)) / ((F * G) * H)

    My response:

     A + B * C * D * E / F / G / H

    Whereupon he objected lamely that division was inefficient...but he gave in when I pointed out that the whole objective of the problem was to get rid of parenthesis.

    Assuming these were floating point numbers, he should have objected that you may have changed the result as the associate law doesn't hold. What's safe to remove is:
     A + B * C * (D * E) / (F * G * H)
  • A. Nonymous (unregistered) in reply to alvatrus
    alvatrus:
    Which makes *every* poster of *any* top comment a loser by default.
    That's why I usually start reading after the frist three or so comments...
  • (cs)

    I'm not sure "copypasta" means what Mark thinks it means.

  • foo (unregistered) in reply to chubertdev
    chubertdev:
    The Big Picture Thinker:
    Or Java or C#, which is essentially VB with curly brackets

    And case sensitivity. Which is the biggest WTF in any programming language.

    Yeah, it really makes more sense to be able to write a program that compiles differently in a Turkish locale. (I'll spare you the details since it's been discussed to often and you can google.)

  • j.albert (unregistered) in reply to very punny

    Hopefully he didn't have a short temper...

  • foo (unregistered) in reply to eek

    [quote user="eek"][quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this. [/quote]

    Your String of data type puns disgusts me.[/quote]Sadly, these unsigned comments always follow the same template. Let's go booling.

  • (cs) in reply to foo
    foo:
    chubertdev:
    The Big Picture Thinker:
    Or Java or C#, which is essentially VB with curly brackets

    And case sensitivity. Which is the biggest WTF in any programming language.

    Yeah, it really makes more sense to be able to write a program that compiles differently in a Turkish locale. (I'll spare you the details since it's been discussed to often and you can google.)

    Did you read "case" as "culture"?

  • foxyshadis (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL

    Well, this guy obviously remember the dictum to never use floats for currency... and picked precisely the wrong solution.

    ¯\(°_o)/¯ I DUNNO LOL:
    TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

    VB? How am I not surprised? (It was either that or PHP.)

    Remember when people who should have known better would earnestly claim that javascript had no addition, and that eval(a+"+"+b) was the only way to do it? Because they screwed up and didn't convert strings from the webform into ints, of course.

  • foo (unregistered) in reply to chubertdev
    chubertdev:
    foo:
    chubertdev:
    The Big Picture Thinker:
    Or Java or C#, which is essentially VB with curly brackets

    And case sensitivity. Which is the biggest WTF in any programming language.

    Yeah, it really makes more sense to be able to write a program that compiles differently in a Turkish locale. (I'll spare you the details since it's been discussed to often and you can google.)

    Did you read "case" as "culture"?

    HTFM.

    Case-folding depends on the locale.

  • Richard (unregistered) in reply to very punny

    [quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this. [/quote]

    Ha, ha. Very guid.

  • Matthew (unregistered) in reply to foxyshadis
    foxyshadis:
    Well, this guy obviously remember the dictum to never use floats for currency... and picked precisely the wrong solution.
    ¯\(°_o)/¯ I DUNNO LOL:
    TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

    VB? How am I not surprised? (It was either that or PHP.)

    Remember when people who should have known better would earnestly claim that javascript had no addition, and that eval(a+"+"+b) was the only way to do it? Because they screwed up and didn't convert strings from the webform into ints, of course.

    eval is evil. The right way to add in JavaScript is

    a - -b

  • qbolec (unregistered) in reply to foo

    why can't you drop the parnthesis around D*E as well? Is it because of overflows?

  • (cs) in reply to foo
    foo:
    eek:
    very punny:
    but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week.
    He was going to need to use a float-ing holiday after this.
    Your String of data type puns disgusts me.
    Sadly, these unsigned comments always follow the same template. Let's go booling.
    Shirley quoting can't be that hard
  • foo (unregistered) in reply to qbolec
    qbolec:
    why can't you drop the parnthesis around D*E as well? Is it because of overflows?
    That, and rounding might be slightly different with a different order of evaluation.
  • uns (unregistered) in reply to Spudley

    [quote user="Spudley"][quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

    He was going to need to use a float-ing holiday after this. [/quote]

    This int what I was expecting. I object that they string me along just for a punchline like that! I'll have to double my efforts to come up with a suitable array of ripostes. [/quote]

    for real?

Leave a comment on “Multiplying Strings”

Log In or post as a guest

Replying to comment #:

« Return to Article