• (cs) in reply to Ytram

    An Hour. An Heir. ... but not an hexadecimal.

  • spork (unregistered)

    Oh come on, you are making this up, right?

     

     

  • somejackass (unregistered)

    I strongly suspect someone just wrote up a perl script to spit out that code. I refuse to believe that, while typing, he couldn't think of a better way to just write out all the damn code. This thesis is not mutually exclusive with paid by the line-ism...


  • (cs) in reply to Iago
    Iago:
    Ytram:

    I think that is proper British english.  I'm not 100% sure, but I know I have see "an" in front of 'h' words quite a bit when reading british articles and literature.

    Nope.  Modern British follows the same rules as American (i.e. you go by the pronunciation, "an hour" but "a hotel").  Traditionally there was a rule that where a word began with "h" and the first syllable was unaccented, then you'd write "an", so "a hospital" but "an hotel", but that is now obsolete and only used by the stuffiest pedants.  No literate Briton ever wrote "an hospital".

    As for the WTF... to think I was joking when I posted something vaguely similar in the other thread!  (Though, to be fair, this is a billion times worse than my version...)


    Yeah, most of the stuff I was basing it on was older english works, but not too terribly old.  And I would definitely call Agatha Christie a literate Brit. [;)]
  • YourCaptchaFailed (unregistered) in reply to Digitalbath
    Digitalbath:

    Maybe he was speaking in pirate.  "An 'exidecimal is upon us, ye lads.  Hard to port!" 



    Congratulations - that's the first time I've ever laughed while reading the Daily WTF
  • (cs)

    C'mon you guys.  I got one word for you: Thorough.  That or "Autism". 

    You'd have to be one determined mutha *shut-yo-mouth* to program this. 

  • (cs) in reply to Iago
    Iago:
    Ytram:

    I think that is proper British english.  I'm not 100% sure, but I know I have see "an" in front of 'h' words quite a bit when reading british articles and literature.

    Nope.  Modern British follows the same rules as American (i.e. you go by the pronunciation, "an hour" but "a hotel").  Traditionally there was a rule that where a word began with "h" and the first syllable was unaccented, then you'd write "an", so "a hospital" but "an hotel", but that is now obsolete and only used by the stuffiest pedants.  No literate Briton ever wrote "an hospital".

    As for the WTF... to think I was joking when I posted something vaguely similar in the other thread!  (Though, to be fair, this is a billion times worse than my version...)


    I hate when people can't remember this rule from 2nd grade English class.  The word "historical" is the one I most often hear abused like this- a lot of times on TV you'll hear people say "it was an historical event."  And it'd be less annoying if they mispronounced "historical" such that the "h" was silent.  But they'll pronounce the "h".

    People do this with words starting with "u" too.  It's <i>an</i> umbrella, but <i>a</i> unicorn.  A long "u" starts with the "y" sound.

    But I digress, this isn't a grammar website.
  • (cs) in reply to PresidentBeef

    Don't forget the C++ / STL version:

    template< typename T >
    std::string ToString( const T& value, std::ios_base& (*base)(std::ios_base&) = std::hex )
    {
        std::ostringstream outs;
        outs << base << value;
        return outs.str();
    }

    Works on any type that has the ostream << operator defined and any radix you want!


  • (cs) in reply to somejackass

    Anonymous:
    I strongly suspect someone just wrote up a perl script to spit out that code.

    Couldn't be.  You wouldn't write comments into the script, would you?

  • Keir (unregistered)

    Wow, It'd be bad if he just didn't realize the language provided functionality for the conversion, but it just shows plain stupidity that once he decided to write a conversion function himself he ended up with that.

    I'd assume pretty much every programmer knows the following table by heart:

    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0000</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0001</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0010</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">2</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0011</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">3</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0100</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">4</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0101</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">5</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0110</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">6</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0111</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">7</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1000</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">8</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1001</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">9</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1010</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">A</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1011</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">B</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1100</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">C</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1101</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">D</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1110</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">E</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1111</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">F</font>

    Us developers use hexadecimal becuase its so damn easy to convert to and from binary.  Every one of the 16 characters matches one of the 16 possible combinations of 4 bytes.

    So worst case scenario, he needed a for loop with a 16 entry select statement...........

    Of course it would have shown some real insight to check the documentation and find the dozen (atleast) various formatting and conversion functions that would do this in a single line.........

  • (cs)

    There are <FONT size=6>10</FONT> types of people:

    Those who understand binary

    Those who don't

     

     

     

  • (cs) in reply to Keir
    Anonymous:
    Us developers use hexadecimal becuase its so damn easy to convert to and from binary.  Every one of the 16 characters matches one of the 16 possible combinations of 4 bytes.

    So worst case scenario, he needed a for loop with a 16 entry select statement...........


    Simpler than a lookup table:
        if( digit <= 10)
           c = '0' + digit;
        else
           c = 'A' + digit;

    That's how I do it.

    /Well, when I need to do it by hand for reasons that I can't seem to remember
    //Didn't have to do it for a long time though
  • (cs) in reply to Zlodo
    Zlodo:
    Anonymous:
    Us developers use hexadecimal becuase its so damn easy to convert to and from binary.  Every one of the 16 characters matches one of the 16 possible combinations of 4 bytes.

    So worst case scenario, he needed a for loop with a 16 entry select statement...........


    Simpler than a lookup table:
        if( digit <= 10)
           c = '0' + digit;
        else
           c = 'A' + digit;

    That's how I do it.

    /Well, when I need to do it by hand for reasons that I can't seem to remember
    //Didn't have to do it for a long time though


    By 'A' + digit, I of course meant 'A' - 10 + digit.

    /The forum ate the - 10
    //No, really
  • uncool (unregistered) in reply to PresidentBeef

    i've done this sorta thing for the sake of "it could be fun".... to be deleted almost immediatly...

    now to use this, that's a whole different story

  • Tolmar (unregistered) in reply to HatTrick
    HatTrick:
    lizardfoot:
    Alex Papadimoulis:
      /**
       * The number of hexadecimal characters per byte.
       */
      public static final int NUMBER_OF_HEXADECIMAL_CHARACTERS_PER_BYTE = 2;
    



    This is my favorite line.  So descriptive, not only in name, but also in documentation. 


    /**
     * this is the value which helps us determine the radius of a circle
     */
    public static final int VALUE_THAT_HELPS_US_DETERMINE_THE_RADIUS_OF_A_CIRCLE = 3.14;

    OMG I am not sure which I am laughing harder at..the WTF or this comment.



    Oh, good.  For a second there, I thought I was going to be the only person who noticed someone declaring Pi as an integer.

    Newsflash!  Value of Pi found to be exactly 3!  "We're Baffled," say scientists.
  • (cs) in reply to uncool
    Anonymous:

    i've done this sorta thing for the sake of "it could be fun".... to be deleted almost immediatly...


    That is, by far, the strangest definition of 'fun' I have ever heard.  (Well, except this one time when I saw a show on the Discovery Channel about people that would put hooks in their body and hang from the ceiling.  That was a little stranger.)
  • (cs) in reply to Tolmar
    Anonymous:
    HatTrick:
    lizardfoot:
    Alex Papadimoulis:
      /**
       * The number of hexadecimal characters per byte.
       */
      public static final int NUMBER_OF_HEXADECIMAL_CHARACTERS_PER_BYTE = 2;
    



    This is my favorite line.  So descriptive, not only in name, but also in documentation. 


    /**
     * this is the value which helps us determine the radius of a circle
     */
    public static final int VALUE_THAT_HELPS_US_DETERMINE_THE_RADIUS_OF_A_CIRCLE = 3.14;

    OMG I am not sure which I am laughing harder at..the WTF or this comment.



    Oh, good.  For a second there, I thought I was going to be the only person who noticed someone declaring Pi as an integer.

    Newsflash!  Value of Pi found to be exactly 3!  "We're Baffled," say scientists.

    That's what it is in Indiana, right?
  • (cs) in reply to WWWWolf

    WWWWolf:
    Looks like the work of a person who didn't know anything about Programming, sat through two lectures of Haskell, and never quite got hang of these Leet Advanced Features...

    There's functional programming and then there's functional functional programming.

    So you're saying this is dysfunctional programming.

    Hmm..., I have to remember to use that sometime.

    --RA

  • (cs)
    Alex Papadimoulis:

      /**
       * The number of hexadecimal characters per byte.
       */

      public static final int NUMBER_OF_HEXADECIMAL_CHARACTERS_PER_BYTE = 2;

    Dork. The comment should be:

       /**
       * The number of hexadecimal characters per byte equals 2;
       */

    --Rank

  • (cs) in reply to lizardfoot
    lizardfoot:


    /**
     * this is the value which helps us determine the radius of a circle
     */
    public static final int VALUE_THAT_HELPS_US_DETERMINE_THE_RADIUS_OF_A_CIRCLE = 3.14;



    Yeeeeeeeeeeey! You made my day!

    How do you do that, store 3.14 in an integer? Redefined what an int is, and used some weird constructors???
  • Aspie (unregistered) in reply to Pope

    All right, my first guess (to be charitable) is that you're simply ignorant.  My second guess is that you're both being ignorant while picking on a subset of the population you believe won't/can't fight back.

    1.  Autism!=stupidity

    2.  More than likely, the attention to detail would express itself in coming up with the most efficient method of solving a problem, though it might possibly blow deadlines out of the water (not that there's anything remotely exclusive when it comes to blowing deadlines out of the water)

    3. Because of that attention to detail, you'd most likely have software that's in perpetual development that the developer in question never feels is release quality, even if the quality is such that the current quality is better than everything else currently available.

     

  • (cs) in reply to VGR
    VGR:
    We are getting close to April 1, after all.


    We're also getting close to Alex's 400th (and, before that, 1000th, if you prefer that) posting. Hope he's got something wonderful in mind 8-|
  • (cs) in reply to PresidentBeef

    This code is just painful to read.  I mean, you couldn't even copy and paste something this bad...

    Imagine this guy writing an octal converter

    Imagine this guy writing a base64 encoder [+o(]

  • Nemo (unregistered) in reply to WWWWolf
    WWWWolf:
    For whatever it's worth, this is what I did once...

    #ifndef ASM_HEXIFY
       const char hexchars[] = {48,49,50,51,52,53,54,55,56,57,1,2,3,4,5,6};
    #  define hex_low(what) (hexchars[((what) & 0x0F)])
    #  define hex_hi(what) (hexchars[(((what) & 0xF0) >> 4)])
    #else
    #  define hex_low(what) hex_low_asm(what)
    #  define hex_hi(what) hex_hi_asm(what)
    #endif

    ...and before you complain about the character values, remember that all the world is not ASCII. =(

    The character values don't matter... just do:

    const char hexchars[] = "012345678ABCDEF";

  • (cs)

    OMFG! This is a classic example of a stupid and stubborn person programming the same way he would break a wall with bare hands - brute force and persistence... I admit that I may be somewhat lazy but that's why I (and actually most of the people I know) after working for a while actually stop and think whether this isn't too hard and if there's another easier way or even something already done by someone else and published on the forums or some site... oh boy, that's what google is for!

  • Nemo (unregistered) in reply to Nemo

    Er, "0123456789ABCDEF".

  • (cs) in reply to cconroy
    cconroy:
    <font size="2">Deal Lord in Heaven.  At least it's nicely commented.  I especially like how he keeps referring to "an hexadecimal".  When did the 'h' become silent?

    </font>
    <font size="5">I</font>n spoken British English a leading H is silent, hence: 'enry 'iggins, 'ermione Granger, Prince 'arry and so on.

  • (cs)

    <font size="5">W</font>ow!  I'm sure that David H's former colleague missed the class teaching arrays and never bothered to pick it up before he graduated.

  • (cs) in reply to Keir
    Anonymous:
    Wow, It'd be bad if he just didn't realize the language provided functionality for the conversion, but it just shows plain stupidity that once he decided to write a conversion function himself he ended up with that.

    I'd assume pretty much every programmer knows the following table by heart:

    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0000</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0001</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0010</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">2</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0011</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">3</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0100</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">4</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0101</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">5</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0110</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">6</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">0111</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">7</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1000</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">8</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1001</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">9</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1010</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">A</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1011</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">B</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1100</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">C</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1101</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">D</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1110</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">E</font>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">1111</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">F</font>

    Us developers use hexadecimal becuase its so damn easy to convert to and from binary.  Every one of the 16 characters matches one of the 16 possible combinations of 4 bytes.

    So worst case scenario, he needed a for loop with a 16 entry select statement...........

    Of course it would have shown some real insight to check the documentation and find the dozen (atleast) various formatting and conversion functions that would do this in a single line.........


    I'm just assuming you mean "Every one of the 16 characters matches one of the 16 possible combinations of 4 bits."
  • Jimmy (unregistered) in reply to kipthegreat
    kipthegreat:

    I hate when people can't remember this rule from 2nd grade English class.  The word "historical" is the one I most often hear abused like this- a lot of times on TV you'll hear people say "it was an historical event."  And it'd be less annoying if they mispronounced "historical" such that the "h" was silent.  But they'll pronounce the "h".

    People do this with words starting with "u" too.  It's an umbrella, but a unicorn.  A long "u" starts with the "y" sound.

    But I digress, this isn't a grammar website.


    And neither is that grammar nor correct. It's phonemics, not grammar. An historical is correct English--British or American.

    The rule is say 'an' rather than 'a' if the consonat is not aspirated. Therefore "an historical" but "a historian."
  • Richard C Haven (unregistered) in reply to Seltsam
    Anonymous:
    It's enterprisey!


    Is that like, "truthiness" ?
  • risk (unregistered) in reply to Hubert Farnsworth
    Hubert Farnsworth:
    lizardfoot:


    /**
     * this is the value which helps us determine the radius of a circle
     */
    public static final int VALUE_THAT_HELPS_US_DETERMINE_THE_RADIUS_OF_A_CIRCLE = 3.14;



    Yeeeeeeeeeeey! You made my day!

    How do you do that, store 3.14 in an integer? Redefined what an int is, and used some weird constructors???


    Clearly, he didn't spell out the rest of the code, because that's the obvious bit...

    /**
     * these are the decimal values of the value which helps us determine the radius of a circle
     */
    public static final char[] DECIMAL_VALUES_OF_THE_VALUE_THAT_HELPS_US_DETERMINE_THE_RADIUS_OF_A_CIRCLE = {'1','4','1','5','9','2', ...};


  • (cs) in reply to Richard C Haven

    Looking at this travesty I'm starting to womder if people aren't doing stuff like this just to get posted on this site. A sort of "Badge of Infamy"? Hey look, I got my code shown on the Daily WTF !!!! HOORAY !!!! :|
    All I can say is that if this is real it's a shining example of why code reviews are required.

    unlisted_error


  • Runtime Error (unregistered) in reply to GoatCheez
    GoatCheez:


    Of course, we all know what we would have done had this project been our baby...


    Well, that depends... am I getting paid by the line?


  • (cs)

    Years ago when I was starting out with PHP my manager needed an online survey app. Nothing too complicated. The managers build the surveys with a number of optional controls. I needed to do some math at runtime that will differ for each survey.

    So I wrote a class that evaluated simple mathamatical formulas following the order of operations.

    I was pretty proud of myself, actually. It wasn't incredibly easy for a new developer. I posted it to a discussion forum.

    Someone said "why didn't you just use eval()?"

    so i renamed it stupid_waste_of_time.class.php

  • Mort (unregistered) in reply to wunderkind

    I have taken to asking prospective coders (for a design verification job, so its fairly low level hardware stuff) to convert hex 19 to decimal for me.  Its amazing how many people can't, or take an inordinate amount of time to do so.  It tends to be very predictive on how well they will do overall.

  • sql_lall (unregistered) in reply to Zlodo

    And the forums also added the '=' in "if(digit <= 10)", right? :p

  • Anonymous Coward (unregistered)

    ...he didn't write a unit test.

  • shadowseeker (unregistered) in reply to Pope

    Couldn't be.  You wouldn't write comments into the script, would you?

    Why not?

    The script would generate comments if that was part of its requirements.

  • (cs) in reply to Ken Nipper
    Ken Nipper:
    Sounds like LOC to me.........
    KLOC
  • koning_robot (unregistered) in reply to icelava

    char inttohex(int i) {
      return '0' + i + ('A' - '9') * (i > 9);
    }

    int hextoint(char c) {
      return c - '0' - ('A' - '9') * (c > '9');
    }


    Good thing I don't work with numbers higher than 15.

  • (cs)

    I'm not buying that, whoever wrote that code was joking.

  • David (unregistered) in reply to SilverDirk
    SilverDirk:
    Oh, and in C its even more fun

    char toHex(int val) { return "0123456789ABCDEF"[val&0xF]; }

    Surely that should be:

    char toHex(int val) { return (val&0xF)["0123456789ABCDEF"]; }

    ;-)

  • (cs) in reply to Sindri

    Uhm..
    LOC..
    Ponder
    LOCo? ;)

  • (cs) in reply to Nemo
    Anonymous:

    The character values don't matter... just do:

    const char hexchars[] = "012345678ABCDEF";


    Actually they did on this machine, since I was, ahem, well, I just let this one speak for itself:

    char *screen = (char *) 0x0401;

    (*(screen+4))  = hex_hi (ch[0].click);
    (*(screen+5))  = hex_low(ch[0].click);

    ... and in this architecture's case, you don't put character values to screen memory, you have to use character screen codes, which the compiler doesn't produce (or maybe it does, I didn't read all docs at that time).

    Can we guess the architecture already? Hint, few people coded in C for it =)
  • (cs) in reply to WWWWolf

    I love the constant "number of hexadecimal characters per byte".

    I heard that the folks at the ISO are planning to redefine the byte to use 16 bits instead of 8. Man, is it ever going to be hell for the programmers - but not for this guy! He's prepared - he just needs to change the constant and it will be all right!

  • Cliff (unregistered) in reply to Ytram
    Ytram:

    I think that is proper British english.  I'm not 100% sure, but I know I have see "an" in front of 'h' words quite a bit when reading british articles and literature.  Older english literature especially.

    It was correct before a stressed H until around the start of the 17th century.  It was revived as an affectation only at the end of the 19th century.  It is certainly neither correct nor in common usage today.

  • (cs) in reply to Tolmar
    Anonymous:
    HatTrick:
    lizardfoot:
    Alex Papadimoulis:
      /**
       * The number of hexadecimal characters per byte.
       */
      public static final int NUMBER_OF_HEXADECIMAL_CHARACTERS_PER_BYTE = 2;
    



    This is my favorite line.  So descriptive, not only in name, but also in documentation. 


    /**
     * this is the value which helps us determine the radius of a circle
     */
    public static final int VALUE_THAT_HELPS_US_DETERMINE_THE_RADIUS_OF_A_CIRCLE = 3.14;

    OMG I am not sure which I am laughing harder at..the WTF or this comment.



    Oh, good.  For a second there, I thought I was going to be the only person who noticed someone declaring Pi as an integer.

    Newsflash!  Value of Pi found to be exactly 3!  "We're Baffled," say scientists.

    PI is equal to 3, or so does the Holy Bible quote.

    The Bible being the word of god and the symbol of everything that's Holy and True, PI is therefore definitely equal to 3
  • (cs) in reply to Digitalbath
    Digitalbath:

    Ytram:
    cconroy:
    <font size="2">Deal Lord in Heaven.  At least it's nicely commented.  I especially like how he keeps referring to "an hexadecimal".  When did the 'h' become silent?

    </font>


    I think that is proper British english.  I'm not 100% sure, but I know I have see "an" in front of 'h' words quite a bit when reading british articles and literature.  Older english literature especially.

    Maybe he was speaking in pirate.  "An 'exidecimal is upon us, ye lads.  Hard to port!" 

    Maybe not...it was funny in my head though.



    Pirate jokes arrh always funny.
  • The Internet (unregistered) in reply to spork

    This one is clearly made up. Total fake. Complete and total BS.

Leave a comment on “To the Hexth Degree”

Log In or post as a guest

Replying to comment #:

« Return to Article