• Bit of Hex (unregistered) in reply to FinnGamble
    FinnGamble:
    Blackice:
    bit = c & mask;
    AH, but by using the AND operation you will lose data. You are, essentially, forcing the bits to be one or zero.
    No he's not. He is merely forcing the bits to be one of 0, 1, 2, 4, 8, 16, 32, 64, or 128.
  • Pauldy (unregistered) in reply to JimmyVile

    I haven't done straight c in some years but I'm pretty sure that JimmyVile 's code won't even compile due to a typo. In addition I'm very suprised at the misdirected hostility towards the initial code bit. I've seen good coders make similar mistakes, 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?

  • GeorgeDundas (unregistered)

    Those colors won't be web safe!

  • ksg (unregistered)

    I've worked on a system where I wrote code that was receiving an object with a hexadecimal id from another system. The developer of that system told me, "Best treat that id purely as a string and not try to parsing it as a hex-represented number. Sometimes as well as the usual 0-9 and A-F, just sometimes, you get a 'G'."

  • Mio (unregistered) in reply to Code Dependent
    Code Dependent:
    I somehow never encountered a file with a "two" bit.
    Of course not. The set of possible values for a bit is {0, 1, FILE_NOT_FOUND}.

    Bits are easy. Just try using a std_ulogic: {Uninitialized, Unknown, 0, 1, High Impedence, Weak Signal, Weak Low Signal, Weak High Signal, Don't Care}

    FPGAs are fun!

  • mauhiz (unregistered)

    The whole concept is flawed. Just generate a random number smaller than 0xffffff, and display its hex representation!

    A warped mind cannot connect.

  • Walleye (unregistered)

    For security purposes, I usually write all the "1" bits to one file and all the "0" bits to another. That way I can just recombine the files when I need to use them.

  • (cs) in reply to Code Dependent
    Code Dependent:
    I somehow never encountered a file with a "two" bit.
    Of course not. The set of possible values for a bit is {0, 1, FILE_NOT_FOUND}.

    or 0, 1 or NULL for those SQL programmers among us.

  • Level 2 (unregistered)

    The bitchecker is not a WTF. He was just using a Setun. http://en.wikipedia.org/wiki/Setun

  • Loren Pechtel (unregistered)

    Somehow, I have a bit of a problem with the code given.

  • Kerio (unregistered) in reply to mauhiz
    mauhiz:
    The whole concept is flawed. Just generate a random number smaller than 0xffffff, and display its hex representation!

    NO SHIT! are you sure?

    captcha: transverbero - it's TRWTF

  • David (unregistered) in reply to Cats!

    0x10 words to be exact.

  • JimmyVile (unregistered) 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);
    ...
    if(bit!=0 && bit!=1)
      printf("Error! Bit=%d\n",bit);
    

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

    I think you should count to 0x10 yourself. ;)

  • RBoy (unregistered) in reply to Code Dependent

    Then how can you afford a shave and a haircut?

  • Dan (unregistered) in reply to Bit of Hex
    Bit of Hex:
    FinnGamble:
    Blackice:
    bit = c & mask;
    AH, but by using the AND operation you will lose data. You are, essentially, forcing the bits to be one or zero.
    No he's not. He is merely forcing the bits to be one of 0, 1, 2, 4, 8, 16, 32, 64, or 128.
    And to think, I always heard that bits could be 0 or 1. But you just said they can also be 2, 5, 8, 16, 32, 64, or 128?!!? I guess they can also be true, false, yes, no, ok, nah, 42, ...
  • Anon (unregistered)

    I sometimes think my bits are in a superposition of both 1 and 0, but whenever I try and look I only see either 1 or 0.

    What's up with that?

  • (cs) 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.
    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?...
  • Mike (unregistered) in reply to Mr B
    Mr B:
    My name:
    > One time, out of boredom, I wrote a little utility > called BitVerifier. It would loop over a folder and > check every bit of each file.

    I'd question it did. The smallest addressable space is the byte.

    If a byte was made out of cream-cheese, I'd agree with you. Unfortunately, it's usually made out of bits.

    Bits are not addressable, however you can load a byte to read a bit within the byte...

  • (cs) in reply to Mike
    Mike:
    Mr B:
    My name:
    > One time, out of boredom, I wrote a little utility > called BitVerifier. It would loop over a folder and > check every bit of each file.

    I'd question it did. The smallest addressable space is the byte.

    If a byte was made out of cream-cheese, I'd agree with you. Unfortunately, it's usually made out of bits.

    Bits are not addressable, however you can load a byte to read a bit within the byte...

    potato potato

  • Anonymous (unregistered) in reply to Bosshog
    Bosshog:
    The goggles, they do nothing!

    My goggles seem to do nothing as well. I still see the same unoriginal comment on each post.

  • (cs) in reply to RBoy
    RBoy:
    Then how can you afford a shave and a haircut?
    0x10 cents.

    Addendum (2009-02-16 13:52): ...allowing for inflation. Of course, when the barbershop ditty was first written, it would have been 0x0A cents.

  • James King (unregistered)

    I like shemales

  • Blackice (unregistered)

    Bender: Ahhh, what an awful dream. Ones and zeroes everywhere... and I thought I saw a two. Fry: Don't worry, Bender: there's no such thing as two.

  • Billy G (unregistered) in reply to Khôi
    Khôi:
    omg! someone found out how scandisk is implemented!
    My lawyers and I were strolling by and we thought of visiting you and see how's everything going.
  • h (unregistered) in reply to jordanwb

    Because it can!

  • (cs) in reply to some crazy chap
    some crazy chap:
    the real wtf fool:
    Mr B:
    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?

    Yes, you are missing something.

    Did you hear the whooosh, Someone?

    [pseudo] if bit_value == 1 return TRUE elif bit_value == 0 return TRUE [/pseudo]

    LOL, n00b. You forget the "else return FALSE".
  • Charles (unregistered)

    Don't forget Schrodinger's bit - it can be 1 and 0 and the same time.

  • (cs) in reply to Mio
    Mio:
    Code Dependent:
    I somehow never encountered a file with a "two" bit.
    Of course not. The set of possible values for a bit is {0, 1, FILE_NOT_FOUND}.

    Bits are easy. Just try using a std_ulogic: {Uninitialized, Unknown, 0, 1, High Impedence, Weak Signal, Weak Low Signal, Weak High Signal, Don't Care}

    FPGAs are fun!

    In some fields of heavy-duty industrial and civil engineering they work with a derived version of std_ulogic that implements {Uninitialized, Unknown, 0, 1, High Impedence, Weak Signal, Weak Low Signal, Weak High Signal, Don't Care, Oh Shit It Shorted Against The EHT Cable RUN FOR IT}

  • (cs) in reply to Code Dependent
    Code Dependent:
    DivineGod:
    This has 10 words too.
    No. This.
  • (cs) in reply to Maurits
    Maurits:
    Code Dependent:
    DivineGod:
    This has 10 words too.
    No. This.

    ^^^ Not that one.

  • (cs)
    One time, out of boredom, I wrote a little utility called BitVerifier. It would loop over a folder and check every bit of each file. If the bit's value wasn't one or zero, it would prompt the user for the correct bit.

    You're going to be in so much trouble if someone runs your program on his quantum computer 50 years from now.

  • (cs) in reply to Maurits
    Maurits:
    Code Dependent:
    DivineGod:
    This has 10 words too.
    No. This.
    *peers over the top of the dugout* Hard to tell at this range, but it looks like a base-zero maths FAIL to me, sarge.

    [EDIT: Argh, he got me! It was a trap!]

  • Paul (unregistered) in reply to Lennart

    +1. Cut the guy some slack.

  • (cs) in reply to Charles
    Charles:
    Don't forget Schrodinger's bit - it can be 1 and 0 and the same time.
    But if you run a program to check it, it gets set to null.
  • Another Funny WP user (unregistered) in reply to FinnGamble

    To that C bunch of code, if I set c to 'a' (or 97 in decimal) I get lots of bit=2 errors, if I print it out what it is giving me, 97 decimal breaks into 01122221. Otherwise it compiles.

    Of course, maybe the

     bit >= VALUE 
    is only appearing as
     bit > VALUE 
    ? (or not, as putting [ code ] around this sample seems to work fine...)

    Switching them from "bit >" to "bit >=" seems to make it work, or at least not print out errors....

  • Scott (unregistered) in reply to Code Dependent

    thankyou cpt. obvious

  • Jay (unregistered) in reply to FinnGamble
    FinnGamble:
    int c=fgetc(infile);
    int bit=c/128;
    if(bit!=0 && bit!=1)
      printf("Error! Bit=%d\n",bit);
    bit=c/64;
    if(bit>2)
      bit=bit-2;
    ... etc ...
    
    That's, afaik, the shortest, easiest and most efficient way to get to the integer values of bits in the C programming language.

    I was about to point out how the program could be made much shorter and clearer with a loop, but then I saw that someone else had already made that point. Then it occurred to me that there is an even shorter and more efficient solution:

    /** Function to list all bits in a folder
    that are neither zero nor one.
    */
    public void listBadBits(File folder)
    {
      System.out.println("Bits in folder "
        +folder.toString()
        +"  that are neither zero nor one: None");
    }
    
  • (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.

    No. I can state categorically and with absolute certainty: Nothing remotely like that ever happened to me.

    I don't mean "making a dumb typo or thinko". That has happened to me. I don't mean "staring at something and looking right past the problem". That has happened to me too. No, what I mean is ...

    The OP:
    //for some crazy reason, sometimes the loop above creates 7 chars. //that is why the below usees substring to get exactly 6 Hex chars. defaultVisualStyle.setColor( "0x" + sb.substring( 0, 6 ) );
    That never happened to me. I never saw a bug, and just gave up, created a crap workaround, swept it under the carpet and hoped it would all somehow be OK. To put it another way, seeing a problem with
    The OP:
    StringBuilder sb = new StringBuilder(); for ( int h = 0; h < 6; h++ ) { int randomHex = randomGen.nextInt(HEX_STRING_VALUES.length); sb.append( HEX_STRING_VALUES[randomHex] ); }
    a piece of code like that, and not adding a line or two that said
    The OP:
    StringBuilder sb = new StringBuilder(); for ( int h = 0; h < 6; h++ ) { int randomHex = randomGen.nextInt(HEX_STRING_VALUES.length); printf ("STRING NOW %s len %d randomHex %d HSV[] %s ", sb, strlen(sb), randomHex, HEX_STRING_VALUES[randomHex]"); sb.append( HEX_STRING_VALUES[randomHex] ); printf ("...STRING AFTER %s len %d\n", sb, strlen(sb)); }
    and making the most basic trivial effort to find out what the problem actually WAS, never happened to me. I think even a beginning programmer should understand the idea of printf-debugging. Hey, you can even single-step through the code in a modern debugger and look at the values of all the variables as they change. The point is, if something is wrong with your data and it doesn't occur to you to try and find out how it got that way, you aren't a programmer at all. You have to ask yourself: if this guy didn't try either of those two techniques, WTF was he doing? Just staring into space and hoping he'd guess the answer? And if he did try either of those two techniques, and didn't see where it went wrong, WTF is wrong with his eyesight?

    NB: I don't speak C# or Java so I used a C printf instead. Inb4 anyone misses the point by not just taking that as a generic illustration rather than an actual working code sample.

  • Your Name (unregistered) in reply to Mike

    Bits are not addressable?

    Okay, obsolete information time! I guess somebody forgot to tell BFEXTU + friends on the 68020 (and above). Essentially these instructions are able to address the entire[*] memory space as one long sequence of bits.

    [*] "entire" on chips with a 24 bit address bus, less with a 32 bit one.

  • wa2flq (unregistered)

    Bender: Ahhh, what an awful dream. Ones and zeroes everywhere... and I thought I saw a two.

    Fry: It was just a dream, Bender. There's no such thing as two.

    CPATCHA Tests discriminate against Robots. Robots have rights two!

  • Adam (unregistered) in reply to valerion
    valerion:
    Ah, good old Base 16-and-a-bit

    It's called 16++

  • Dan (unregistered) in reply to Mr B

    Not true. The smallest addressable space on noms is a nibble.

  • snoofle (unregistered) in reply to Your Name
    Your Name:
    Bits are not addressable?

    Okay, obsolete information time! I guess somebody forgot to tell BFEXTU + friends on the 68020 (and above). Essentially these instructions are able to address the entire[*] memory space as one long sequence of bits.

    [*] "entire" on chips with a 24 bit address bus, less with a 32 bit one.

    Also, the old TI 340xx series processors were bit-addressable.

  • Anon (unregistered)

    'For some crazy reason, this individual won't be writing code in this project anymore.'

    Wow, have you listened to yourself recently? What do the people around you think of you?

    Now, can we have the ball back please?

  • pooper (unregistered) in reply to Mr B

    As if he could not read a byte and extract each bit?

  • (cs) in reply to Walleye
    Walleye:
    For security purposes, I usually write all the "1" bits to one file and all the "0" bits to another. That way I can just recombine the files when I need to use them.

    I do that too ... did you remember to pad the 1s with 0s and the 0s with 1s so you can put them back together with the 1s and the 0s in the right positions?

  • Scott (unregistered) in reply to Harry Carey

    I would. I'd eat it and then ask for seconds. And then polish it off with a tall cool Budweiser. I would do it. .... Hey! What about this?

  • Craftsman (unregistered) in reply to Code Dependent
    Code Dependent:
    I somehow never encountered a file with a "two" bit.
    Of course not. The set of possible values for a bit is {0, 1, FILE_NOT_FOUND}.

    Hah, you haven't been in computers long have you? They are Binary! So ranges are always some multiple of 2: {0, 1, FILE_NOT_FOUND, EOF}

  • Pim (unregistered) in reply to Charles

    Yay! I made it through the captcha!

    Charles:
    Don't forget Schrodinger's bit - it can be 1 and 0 and the same time.

    But, no no no, you misunderstand. Schrodinger's bit is not 0 and 1 at the same time. It is neither 0 nor 1, until you look at it with the bit verifier program. That's what the bit verifier is for! I question the thoroughness of said program though. Did it only test for 0, 1 and 2? So it would have missed bits with value -1, hm?

  • 2beers (unregistered) in reply to Code Dependent

    The most valuable bit: http://www.bitburger.com/bitburger_beers/index.html

Leave a comment on “Some Crazy Reason”

Log In or post as a guest

Replying to comment #:

« Return to Article