• (cs) in reply to bcammack
    Anonymous:
    I can't help but feel that this is an example of how a person can be intelligent and educated regarding computers and programming, but doesn't have that creative "something" that makes a truly good programmer.   Yeah, it compiles and yeah, it works, but...


    IMO that "something" is simply a bit of laziness and a strong aversion to repetitive, boring tasks. It makes you think "there MUST be a better way to do this" and then find that way.

  • Hendrik (unregistered) in reply to Ytram
    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.


    It's called ‘dropping you H’s’.  There is this nice article about it, called Dropping you Aches, if I remember well, but I couldn’t find it.

    captcha = register, nice one.
    second try: captcha = ernest (somebody been reading Wilde?)
    third try: captcha = register (again)
    fourth try: captcha = screen
    fifth: real
    sixth: fortune
    platinum (I'm losing my temper here)
    zork
    register
    ah, damn, It was my name I didn't fill in
  • rob3rt (unregistered) in reply to Ytram
    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.


    It's "proper" British English only if the word when pronounced tends to lose its non-vowel initial sound. "An Hotel" would sound like "An Otel" since the H is often lost, exposing the O. "An Horrible Day" would sound generally like "An Orrible Day" similarly.

    Saying "An Hexadecimal" as "An Exidecimal" does sound a bit common though!
  • (cs)

    I would print this code, and carry with me to the indoor sanitation. But I would need to search skinfriendly ink/toner, and a printer could print on a 'very special' paper.[;)] I would read 'from cover to cover', then the already read sections would be...destroyed.[8-|]

  • alexp (unregistered)

    Oh, God... This isn't true. I'm not kidding, I don't believe this is genuine.

  • (cs) in reply to masklinn

    I once heard a mathematician tell this joke: Pi is equal to 3 for sufficiently small values of pi, or sufficiently large values of 3.

    I think I prefer pirate jokes.


  • Barnacle Wes (unregistered) in reply to Oliver Klozoff
    Oliver Klozoff:
    I want to see his Octal class.



    Maybe that will only be 2,500 lines long?  pi
  • Barnacle Wes (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.



    You dummy, that's not 3.14, it's THREE.  I know it is so because the BIBLE told me so!
  • (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.

     
    "Hard to port"!  Easy to reimplement, though!  [:D]
  • (cs) in reply to Zlodo
    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


    I'm sure i'm WAY too late to point this out, but hex(10) shouldn't be "10"

          -dave-
  • Dirk (unregistered) in reply to PCBiz

    And then again, maybe the programmer wrote a very nice, small, elegant code generator to generate thousands of LO such C for him. :-)

  • CalliArcale (unregistered) in reply to Dirk

    I do know engineers who, when faced with the sensible absurdities (that's only a contradiction if you've never worked in the defense industry) of their day-to-day jobs, will protest against those absurdities with monstrosities like this.  Even people who are not paid per SLOC.  Even people who are not paid by the hour.  It's a form of rebellion.  (It doesn't sound as if that was this guy's problem, though.)  Annoyed at a coding standard that requires you to comment even the bloody obvious?  Comment absolutely everything!  Irked that your program's performance is evaluated in terms of SLOC without regard for code complexity or anything like that?  Take SLOC to its logical extreme!  I could definitely see several people I know writing a beautiful piece of very simple software that produces this huge pile of (nevertheless perfectly functional) crap just because.  Add in a boring project without enough challenge, and you start looking for ways to make your job more interesting.

  • (cs) in reply to CalliArcale

    Anonymous:
    ........Take SLOC to its logical extreme!  I could definitely see several people I know writing a beautiful piece of very simple software that produces this huge pile of (nevertheless perfectly functional) crap just because. .........

    On the other hand I had people working for me who handed me similar code just because they didn't knew about the proper APIs and on the other hand they didn't want to look stupid and bother asking so they really worked hard to do what they were asked for. I always wonder how people keep using cut-n-paste in cases where writing a simple function would not only simplify their job but also help maintain the code in the future and that's just the beginning of the advantage list.

     

    Here's a piece of code from someone I interviewed and this is what I got when I asked for "code you have written yourself and is part of an actual production system, not your graduation project":

    procedure Tfrmobr.Edit58KeyPress(Sender: TObject; var Key: Char);
    begin
    if not (key in [#8,#44,#48..#57]) then key:=#0;
    if key=#46 then Key:=#44;
    if key=#44 then
       if pos(key,edit58.text)<>0 then key:=#0;
    end;

    procedure Tfrmobr.Edit59KeyPress(Sender: TObject; var Key: Char);
    begin
    if not (key in [#8,#44,#48..#57]) then key:=#0;
    if key=#46 then Key:=#44;
    if key=#44 then
       if pos(key,edit59.text)<>0 then key:=#0;
    end;

    <snip>... + a fiarly large number of other fields with similar event handler, that were actually named like "edkolm3" or "edkolt".

     

    Notice the nice component naming convention "Edit58" or "Edit59". I won't even mention the magical numbers... What really bugs me here is that instead of 100 similar functions it all could be:


    procedure Tfrmobr.EditKeyPress(Sender: TObject; var Key: Char);
    begin
    if not (key in [#8,#44,#48..#57]) then key:=#0;
    if key=#46 then Key:=#44;
    if key=#44 then
       if pos(key,TEdit(Sender).text)<>0 then key:=#0;
    end;


    Changing something in the behaviour of all these boxes would later cost at least a day of fixing and debugging instead of 5 minutes coding and 5 minutes testing... And I would be paying the salary in this time, am I not?

    I admit I'm a bit lazy, but I'm amazed everytime I see this, how is it possible, that people keep working on something like this without stopping at one point to think for a while if there isn't an easier way to do it with less efforts.

  • CalliArcale (unregistered) in reply to nsimeonov
    nsimeonov:
    Here's a piece of code from someone I interviewed and this is what I got when I asked for "code you have written yourself and is part of an actual production system, not your graduation project":


    I have to agree about the laziness; some people will do a lot of work to avoid finding out how to do it the easy (and generally better) way.

    However, I do take some issue with asking people to provide code they wrote which is part of a production system.  I have written a lot of code for production systems, but it is not mine to give away.
  • (cs) in reply to CalliArcale

    I just want to see something real, I need a couple of functions and I don't even care what they do, all I do care is to see how this person writes code. I am aware about NDAs etc, but so far I didn't have a situation with anyone who's unable to show anything because he/she is bound by contracts etc.

    On the other hand I had people working for me asking for permission to show some of the code they actually wrote to other companies during an interview and I had no problem with this either.

  • CalliArcale (unregistered) in reply to nsimeonov

    Well, that's okay then.  ;-)  I know I could get in a lot of trouble if I removed any of my code from the building, so you'd be stuck with examples of personal projects.  I guess I ought to come up with some more personal programming projects!

  • (cs)

    Funilly enough Java already has a method to convert and int to hex

    private static char convertBitsToHexadecimalCharacter( boolean bit1,
                   boolean bit2,
                   boolean bit3,
                   boolean bit4) {
      int decVal = 0;

      /* Convert bool to Decimal */
      if (bit1) decVal += 1;
      if (bit2) decVal += 2;
      if (bit3) decVal += 4;
      if (bit4) decVal += 8;

      /* Convert Decimal to Hex (+ Guy wants in it capitals) */
      return Integer.toHexString(decVal).toUpperCase().charAt(0);
     }

    for a uni student i'm happy, please bag the crap out of this if its WTF worthy!!!

  • (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.


    Minor corrections:

    "an hexadecimal" would be part of the modern standard British (imperial) dialect, which was invented around 1750. Still rare, though.

    Pirate would be "a f***ing (h)ex! hard a-larboard! aarrrh!". For the modern version of the dialect, check these guys out.

  • Amit (unregistered) in reply to Ytram

    A lesson on language

    The ‘H’ words beginning with the sound of a vowel have are preceded by the article ‘an’.

    Example: "It's and honour to comment here" "I saw this an hour ago" "You are an honest person"

    As opposed to:

    "It is surely a hexadecimal" "Everybody needs a home”"

    Cheers

    Amit

  • Grnch (unregistered) in reply to Tony Morris
    Tony Morris:
    I challenge the assertion that the original post is a one-liner in Java (for some definition of one line).

    The biggest WTF here is that even those commenters who tried to show how it's done missed the point by only giving a way to convert integers to hex strings, while the original request was to convert byte arrays. What if the byte array is bigger than what can fit in Java's int or long?

    So, to answer your challenge, here is the Java one liner to convert a byte array to hex string, in all its glory:

    String hex = new BigInteger(1, theByteArray).toString(16);

    The BigInteger class is in the java.math.* package and can handle arbitrary sized byte arrays, up to the limits of available memory.

    P.S. The fact that I'm replying to a nearly 2 year old thread is a WTF in itself, but I was browsing the archives and couldn't resist.

  • Muchsake (unregistered) in reply to BlackTigerX

    I one worked on a mainframe computer (I think it was Burroughs) that used three nibble bytes (octal so 3,3,3)

  • (cs) in reply to stephen
    stephen:
    cconroy:
    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?

    Maybe he's french.

    In the U.S., at least, they used to teach that it was always "an" before an "h." (I don't know what the scholars said, but this was the common teaching.) I realized that this didn't make sense, and so surrreptitiously only used "an" when the "h" was silent. I thought I was a maverick.

Leave a comment on “To the Hexth Degree”

Log In or post as a guest

Replying to comment #:

« Return to Article