• (cs) in reply to Lennart
    Lennart:
    Seems like a junior programmer, which made a small error and blind stared on it for a while and finally giving up. Can happen. His mentor should help him and both move along.

    Don't tell me nothing like this ever happened to you people.

    Sure it did. Once, when I was 6 and still believed in ghosts and monsters, I heard about HEX NUMBERS and thought they cast a spell; I couldn't figure out how to make the right words to make it work right, though.

    By the time I could actually get a job (at 12), I knew that the valid hex digits were only 0-F and did not include '10', 'G', or 'V8'.

  • woot. (unregistered)

    "For "some crazy reason," the output could be up to twelve characters."

    No, it could not? Always 6 unless the "10" is included, then 7...

  • (cs) in reply to My name
    My name:
    No a problem per se. But it may as well be stored in ternary on the disk for all you'd know. When you say "check the bits", you don't check physical bits on your physical drive. Nor on any physical memory. Your program semantics include operators that yield ones or zeros. Not the same thing.

    But quite some hair-splitting.

    Alright, I'll get my coat.

    Um, nope. Bits and bytes on disk too, I'm afraid, so just 1s and 0s.

    Button up, now. It's cold out there.

  • (cs) in reply to jordanwb
    jordanwb:
    Why would a bit be something other than 0 or 1?

    Do you start "how to use common sense and thought to learn to grasp humor" in school soon? Like, maybe next year in third grade?

  • (cs) in reply to Craftsman
    Craftsman:
    Hah, you haven't been in computers long have you?
    Wow... I've never been in a computer.
  • (cs) in reply to JimmyVile
    JimmyVile:
    Yes I got the joke, I'm just bored waiting for a large compile job.

    Why? So that when the programmer doing the compiling is done you can unplug the computer and plug in your vacuum?

  • (cs) in reply to Code Dependent
    Code Dependent:
    Addison:
    methinks:
    obvious:
    The problem with the code is that hexadecimal doesn't include "10". 1,2,4,5,6,7,8,9,A,B,C,D,E, and F are the only valid hexadecimal numbers.
    Of course, it would help his cause slightly if he'd included "3"...
    And 0...
  • (cs) in reply to Someone

    What did you say the purpose of the BitVerifier app was in the helpfile? "To prevent Bender from having nightmares reading this program"?

    FinnGamble:
    My name:
    I'd question it did. The smallest addressable space is the byte.

    Lol n00b.

    <insert real WTF here>
    

    That's, afaik, the shortest, easiest and most efficient way to get to the integer values of bits in the C programming language.

    my GOD, have you ever heard of a bitwise operator? I don't think you have. Or possibly you're just being extremely sarcastic and I missed it.

    (assuming you read the whole file into a buffer large enough to fit it, not going to complicate things with a chunk based file reader...)

    for (int i = 0; i < lengthoffile; i++)
        for (int j = 0; j < 8; j++)
            if ((filebuf[i] & (1<<j)) == 2)
                printf("byte containing a bit with value 2 found at offset: %u.  byte value: %hhX\n", i, filebuf[i]);
    </pre>
    
  • (cs) in reply to Adam
    Adam:
    valerion:
    Ah, good old Base 16-and-a-bit

    It's called 16++

    You do know that modern compilers will optimize that to ++16, don't you?

  • (cs) in reply to Erik

    [quote user="Erik"][quote user="Someone"]The real WTF here is that you wrote a utility that looped though files checking if each Bit is a 1 or 0...

    Am I missing something or is that kind of redundant? ]/quote]

    Agreed. This story makes no sense. It would make sense if the author wrote a program to hash a file's contents and verify it against a list of pre-determined values. But to read a bit in memory and make sure it's 0 or 1. WTF? That's like checking batteries to make sure they only have positive and negative terminals.[/quote]

    I've made an appointment at the shop for both of you to have those broken humor detectors repaired, although I'd suspect they're so badly damaged they'll require replacement instead. I hope your warranty is still good, although they've probably been broken so long that it's run out.

  • (cs) in reply to obvious
    obvious:
    The problem with the code is that hexadecimal doesn't include "10". 1,2,4,5,6,7,8,9,A,B,C,D,E, and F are the only valid hexadecimal numbers.

    Gee, thanks! None of the other thousand readers would have been able to figure that out on their own, much less already have posted about it!

    GUYS! We finally have a real genius among us! Who's buying the first round to celebrate?

  • (cs) in reply to J Schalken
    J Schalken:
    Wait, what exactly does the length of HEX_STRING_VALUES have to do with the length of sb?

    If HEX_STRING_VALUES happened to be the entire alphabet - 26 characters - then each character in sb will have 26 possible values...but sb should still contain exactly 6 of them, because the loop should always be executed exactly 6 times.

    Or is my understanding of the code just plain wrong?

    Your understanding is plain wrong. The sb could contain 7 characters if one of the matches was the erroneous value "10", which is 2 characters long. Or it could be 12 characters wrong, if the "10" value was fetched each of the 6 times the array was read.

  • (cs) in reply to woot.
    woot.:
    "For "some crazy reason," the output could be up to twelve characters."

    No, it could not? Always 6 unless the "10" is included, then 7...

    Unless the "10" comes up more than once, in which case it's more. What happens if "10" comes up all 6 times? Is "101010101010" 6 or 7?

    If you're going to reply, think first. You don't look so foolish that way.

  • (cs) in reply to Code Dependent
    Code Dependent:
    Addendum (2009-02-17 08:26): Of course, it would help his cause slightly if he'd included "3"...
    Hey, if he's going to miss out the very first one, why expect him to get the rest right?

    (And it'd help if I didn't wait so long before hitting 'Submit'.)

  • Erycius Puteanus (unregistered)

    At least in theory. I somehow never encountered a file with a "two" bit.

    Try humming, or knocking, or honking "Shave and a haircut". Your "two" bit will soon follow.

  • (cs) in reply to nah
    nah:
    Sutherlands:
    nah:
    Easy to fix. Just do a search and replace. Changing every 10 in the result to A, no need to change the array.
    His fix is just as valid as this one. His just has more 1s and 0s than you would expect from a random function, and yours would have more As than you would expect from a random function. If you're going to do this from other code, treating this like a black box, you're going to get 5-char strings. If you're instead going to change the code, why not just fix the array?...

    Whooosh

    Must be my sarcasm detector that's broken. Yeah... that must be it...

  • (cs)

    No, the real WTF is that he didn't declare 0 and 1 as variables. What a poor programmer to hard code numeric values into their code.

    #define BIT_ZERO 0 #define BIT_ONE 1

    You know, in case they have to change in the future...

  • (cs) in reply to nobody
    nobody:
    DaveK:
    Not "back when [it] was first written", they weren't. 10 qatloos for the first poster who knows what the real name of the tune originally was. (Hint: think old money. Then think about the OP we're responding to. Then you'll know why there's four of them to the byte or dollar.)

    two bits.

    Congratulations sir, a winrar is you!

  • (cs) in reply to GooberMcNutly
    GooberMcNutly:
    No, the real WTF is that he didn't declare 0 and 1 as variables. What a poor programmer to hard code numeric values into their code.

    #define BIT_ZERO 0 #define BIT_ONE 1

    You know, in case they have to change in the future...

    Surely TRWTF is you calling those two constants "variables"...?

    (inb4 "no u, pedant")

  • (cs) in reply to IByte
    IByte:
    the real wtf fool:
    The code is fun, but WTF kind of application would require a random colour generator anyway?
    I can think of several things. Tabkit comes to mind, for instance (although those colours may have been picked from a restricted palette rather than from the entire colour space).

    I think they have special code in tabkit to generate the most vile and unrestful colours possible. It's definitely not random across all values.

  • (cs) in reply to the real wtf fool
    the real wtf fool:
    The code is fun, but WTF kind of application would require a random colour generator anyway?

    The desktop publishing software used by Wired Magazine?

  • (cs)

    The real WTF is that even after four pages of comments, nobody has noticed the typo in the original coder's comment.

    //that is why the below usees substring to get exactly 6 Hex chars.
  • (cs) in reply to TGV
    TGV:
    FinnGamble:
    My name:
    I'd question it did. The smallest addressable space is the byte.
    Lol n00b.
    int c=fgetc(infile);
    ...
    
    That's, afaik, the shortest, easiest and most efficient way to get to the integer values of bits in the C programming language.
    If your irony detector hasn't been calibrated for some time, count until 0x10 before replying to this comment...
    Your's hasn't been, either. Now where do I get my bonus points?
  • (cs) in reply to Pauldy
    Pauldy:
    ... for me the WTF isn't in the code that includes the 10 it's in the fix that simply truncates the result instead of fixing the original problem. It's quite apprent when they ran into the problem of the random extra character it never occured to them there was a problem in the function that generated the result instead opting for the quick fix that just truncated the result. WTF man?
    That approach is called cargo cult programming, and I'm trying my darndest to discourage it on the mailing lists I frequent. You would not believe how widespread it is. People just try things left and right "till it works", do NOTHING to check if their fix actually fixes the real problem, and just move on. If you mix this attitude into embedded programming, you get all sorts of gems. Engineering is obviously far removed from software in some people's minds...
  • Val (unregistered) in reply to woot.
    woot.:
    "For "some crazy reason," the output could be up to twelve characters."

    No, it could not? Always 6 unless the "10" is included, then 7...

    Why do you think a random generator cannot generate the same number multiple times? A true random generator could generate 6 times "10" in a row, with a probability of 1/17^6. I'm pretty sure a pseudo-random generator would never do this, however to do it 2, or maybe 3 times (so having a length of 8 or 9), is possible.

  • (cs) in reply to Pim
    Pim:
    The real WTF is that even after four pages of comments, nobody has noticed the typo in the original coder's comment.
    //that is why the below usees substring to get exactly 6 Hex chars.
    The real WTF is that even after four pages of comments, you haven't noticed nobody cares.
  • (cs) in reply to kastein
    kastein:
    my GOD, have you ever heard of a bitwise operator? I don't think you have. Or possibly you're just being extremely sarcastic and I missed it.
    *Possibly* you've not been trolled silly and I missed it. But I doubt it.

    Seriously though: if you find yourself writing a disclaimer that amounts to "Oh shit, I know I'm being gullible", you really ought to stop and think again before you hit "submit".

  • (cs) in reply to DaveK
    DaveK:
    Pim:
    The real WTF is that even after four pages of comments, nobody has noticed the typo in the original coder's comment.
    //that is why the below usees substring to get exactly 6 Hex chars.
    The real WTF is that even after four pages of comments, you haven't noticed nobody cares.
    I would have thought that four pages of comments meant that people cared!

    Then again, I know I'm being gullible.

  • Wyrd (unregistered)

    The good thing about this wtf is that, unlike some of the previous ones with lots and lots of code, this one's easy to understand.

    For people that don't ever do much/anything with hexadecimal, the initial mistake is almost excusable. That the person did not catch it upon testing, and that they chose to hack-fix it with the substring job is not excusable.

    -- Furry cows moo and decompress.

  • FinnGamble (unregistered) in reply to kastein
    kastein:
    my GOD, have you ever heard of a bitwise operator? I don't think you have. Or possibly you're just being extremely sarcastic and I missed it.
    I kinda put some clues in: "Lol n00b" "afaik" "the shortest, easiest and most efficient" "the integer values of bits" "the C programming language"

    But maybe I was too subtle.

  • (cs)

    Reminds me of when I was a kid and my first grade teacher was wondering what was wrong with my home life... when I counted in school it was like this: "... nine, ten, jack, queen, king..."

  • Félix (unregistered)

    TRWTF is that setColor takes a string as an argument.

  • thg (unregistered)

    baker's hex

  • (cs) in reply to Pim
    Pim:
    DaveK:
    Pim:
    The real WTF is that even after four pages of comments, nobody has noticed the typo in the original coder's comment.
    //that is why the below usees substring to get exactly 6 Hex chars.
    The real WTF is that even after four pages of comments, you haven't noticed nobody cares.
    I would have thought that four pages of comments meant that people cared!
    It's odd, the things that WTFers choose to pick on and the things we choose to let slide in any given WTF. The group consciousness is an erratic and unpredictably irrational beast.
  • randomo (unregistered) in reply to Code Dependent
    Code Dependent:
    Addison:
    methinks:
    obvious:
    The problem with the code is that hexadecimal doesn't include "10". 1,2,4,5,6,7,8,9,A,B,C,D,E, and F are the only valid hexadecimal numbers.

    You don't say...

    Or perhaps my sarcasm detector needs some serious recalibration...

    His name is "Obvious". Recalibration indeed.
    I don't think so. There's no sarcasm in stating a simple fact which is already known by everyone, regardless of what name you use.

    Addendum (2009-02-17 08:26): Of course, it would help his cause slightly if he'd included "3"...

    And er, zero as well perhaps?

  • Anon (unregistered) in reply to valerion

    I love how these things always say "this individual won't be writing code in this project anymore". So we fire someone when they do something wrong?

  • Jazzman (unregistered)

    Sometimes there are reasons why some ppl NEVER should try to do programming...

    I think this case is pretty clear on that.

  • Smitty (unregistered) in reply to Code Dependent

    Wouldn't the 'two' bit be the second least significant bit ?

  • Jeh-fuh-fuh (unregistered) in reply to nah
    nah:
    Easy to fix. Just do a search and replace. Changing every 10 in the result to A, no need to change the array.
    Ummm... joke, right? Or did you forget that all the following values are off-by-one?
  • aProgrammer (unregistered)

    WTF. Since when hex numbers started having "10" as valid value. The valid values should be 0-9 and A-F (representing the base 16). 0-10 and A-F will be 17 different numbers. Good that programmer is out of project.

  • Stevie D (unregistered) in reply to mxsscott

    No, I pad my 1s with 1s, and my 0s with 0s ... is that not right? On the upside, it does make them more easily recyclable ...

  • redengin (unregistered) in reply to Code Dependent

    "2bit" is the value of your BitVerifier. :)

Leave a comment on “Some Crazy Reason”

Log In or post as a guest

Replying to comment #244316:

« Return to Article