• caper (unregistered)

    "Then how is the code going to run?"

    Because the code is reading the power from an attached device, not itself.

  • barf4eva (unregistered)

    You'd think the poor fella was a GenTran programmer..

  • Smegzor (unregistered)

    Amatures!

    It doesn't handle FILE NOT FOUND.

  • acpi=off (unregistered)

    Judging from some of the BIOS versions you found in Laptops during the last decade, I wonder if the same dev switched to writing firmware code in C after writing this...

  • Dave (unregistered)

    I hope he wrote a script to generate that.

  • Gibbon1 (unregistered) in reply to Shinobu

    [quote user="Shinobu"][/quote]Meanwhile, in VB you don't need := or == since it's always clear from context which is meant. You don't assign in expressions, and a comparison can never be a statement. It makes sense, is clear, you can always use =, and you never get weird bugs from accidentally using = instead of ==.[/quote]

    Two defenses of == vs =. During tokenization == and = resolve into two separate tokens whose meaning is unambiguous and does not have to be inferred by context. Consider, for(i=0; i==b; i+=2) what do? This decision resulted in a much simpler and faster compiler.

    Second modern compilers will bitch at you if you write if(a=b) so if it causes a problem for you it's your own damn fault. C was never designed with the idea of being a nanny like Basis or Java. You can write 'clever' code and step on your own dick and the language won't stop you.

    Third you get used to it, when I typed if(a=b) above I automatically double tapped the = key and had to backspace.

  • Jason (unregistered)

    People who code like this really.. well, how do they even graduate? How do they stay employed? Shouldn't someone just tap them on the shoulder and say, you know, software engineering is just not for you?

  • Rourke (unregistered) in reply to Nagesh

    The newspaper is in Bengali, common in eastern India, not common in Hyderabad on the other side of the country. At least troll right.

    Nagesh:
    Maths by decimel is not being hard. Invented by Indian in fact at Hyderabad Unaversity: [image]
  • Corporate Programmer (unregistered)

    Thats not a WTF. He got paid by lines of code.

  • (cs)

    You had me at "VB".

  • (cs) in reply to LetMeFinclOut
    LetMeFinclOut:
    Ol' Bob:
    snoofle:
    Ben Jammin:
    Yeah, this could be drastically improved with a switch statement.
    Not enterprisey enough; what if they need the values in different bases? Needs XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <doc>
       <Fractions>
          <value>
             <reading>1.0"</reading>
             <percentDecimal>100.0%</percentDecimal>
             <percentOctal>144.0%</percentOctal>
             <percentHex>64.0%</percentHex>
             <percentBinary>1100100.0%</percentBinary>
          </value>
          <value>
             <reading>.999"</reading>
             <percentDecimal>99.9%</percentDecimal>
             ...
          </value>
          ...
          <value>
             <reading>0.01</reading>
             <percentDecimal>1.0%</percentDecimal>
             ...
          </value>
          ...
          <value>
             <reading>0.001</reading>
             <percentDecimal>0.1%</percentDecimal>
             ...
          </value>
          <value>
             <reading>0</reading>
             <percentDecimal>Your battery has no power - you can't see this</percentDecimal>
             ...
          </value>
       </Fractions>
    </doc>
    

    [Edit] RichP - you just beat me to it

    ROFLMAO!!!!

    Indeed. This may be the Rube Goldberg of percent calculations.

    This is actually a textbook scenario where XSLT is the worst of all possible choices. And that's when you add Javascript and descend one node in Dante's Inferno.

  • Craven Weasel (unregistered) in reply to Gibbon1

    [quote user="Gibbon1"][quote user="Shinobu"][/quote]Meanwhile, in VB you don't need := or == since it's always clear from context which is meant. You don't assign in expressions, and a comparison can never be a statement. It makes sense, is clear, you can always use =, and you never get weird bugs from accidentally using = instead of ==.[/quote]

    Two defenses of == vs =. During tokenization == and = resolve into two separate tokens whose meaning is unambiguous and does not have to be inferred by context. Consider, for(i=0; i==b; i+=2) what do? This decision resulted in a much simpler and faster compiler.

    Second modern compilers will bitch at you if you write if(a=b) so if it causes a problem for you it's your own damn fault. C was never designed with the idea of being a nanny like Basis or Java. You can write 'clever' code and step on your own dick and the language won't stop you.

    Third you get used to it, when I typed if(a=b) above I automatically double tapped the = key and had to backspace. [/quote]

    The same tokenization happens with ALGOL/Pascal/et al's handling of := and =.

    And I tend to automatically type := then have to correct it when making one of my rare forays into curly-brace land.

    I've always wondered if a colon was hard to type on PDP teletype keyboards (or whatever was used to input the code). Like {} apparently are on some non-US keyboards. And I automatically type := and then have to remove it

  • (cs) in reply to frits
    frits:
    Hey this is VB, why don't they just mulitply the string by 100 and concatanate the "%" character?
    But then you'd have 100 strings! You want to concatenate a "%" to all of them? That would be very processor intensive!
  • (cs) in reply to DonaldK
    DonaldK:
    Stabbitha:
    Obligatory "The real WTF is VB..."

    Now back to getting paid to write VB ... sigh ...

    You realise it's 2012...? I honestly hope you're not referring to VB6.

    O bother that's worse than those who were being paid for COBOL programming for Y2K fixes...

    Have you ever even SEEN business COBOL code?
  • musbur (unregistered)

    This is a stupid and long-winded implementation of a solution much better suited for a lookup table.

  • Racist? (unregistered) in reply to Nagesh
    Nagesh:
    Maths by decimel is not being hard. Invented by Indian in fact at Hyderabad Unaversity:

    (Image of Kolkata street vendor removed)

    I can only assume that "Nagesh" is another grossly obese burger-munching American with a gun collection and a single figure IQ who thinks India is "somewhere near Hawaii".

  • (cs) in reply to Racist?
    Racist? :
    Nagesh:
    Maths by decimel is not being hard. Invented by Indian in fact at Hyderabad Unaversity:

    (Image of Kolkata street vendor removed)

    I can only assume that "Nagesh" is another grossly obese burger-munching American with a gun collection and a single figure IQ who thinks India is "somewhere near Hawaii".

    He's the spitting image of an actual Indian we had here once, I believe. Someone started to make fun of him by using his name, since neither was registered, and there was a long, hilarious fight before the troll finally registered as Nagesh, beating the real Nagesh to the punch.

    Really, though, it's almost impossible to tell them apart.

  • Hahaha (unregistered) in reply to Ben Jammin

    You're almost as funny! ;-)

  • andrey (unregistered) in reply to Ben Jammin

    made me lough!

  • HonoredMule (unregistered)

    I love code like this. I get a huje jolt of pleasure anytime I can easily collapse 10+ lines of code into 3 or 5 that are even easier to understand.

    After that I can think to myself that no matter bad things are, at least they're getting a lot better. :)

  • pointyhaired (unregistered) in reply to Lone Marauder
    Lone Marauder:
    Dear Sweet Lord. I'm not a coder, just a lowly network geek... and *I* wouldn't write a script like that.
    Yes, you would ..... if your individual performance was tied to SLOC count.

    I can easily see something like this happening. "If they're going to measure my productivity by SLOC, then by God I'll give them SLOC!"

  • CRE (unregistered) in reply to slamers
    Maybe we need to start forcing programmers to have a license to be able to operate - just like we do for many other professions...

    Because regulation has worked out so well in other industries...

    This kind of code is what happens in a world where programming is still not recognized as fundamental to a well-rounded, modern education. If it were, employers would know enough to differentiate between completely ridiculous and merely bad work as they generally can when managing other subordinate fields in which they lack complete expertise.

  • Daniel (unregistered)

    A place in Programming Pearls is secured.

  • Leandro (unregistered)

    We are all treating this developer as an copy-paste idiot, but I can bet that he actually spent a whole day to write a script to auto-generate that bit of code... to avoid copy-pasting! :D

    Thas is genius... or madness... you choose.

  • Oliver (unregistered) in reply to Ben Jammin

    This could be drastically improved with about anything.

Leave a comment on “The Percent Conversion”

Log In or post as a guest

Replying to comment #:

« Return to Article