• (cs) in reply to ParkinT
    ParkinT:
    WOW. That's not "reinventing the wheel". That is Reinventing Fire!!!
    Play by the rules or you will get burned.
  • Earp (unregistered)

    I remember in my first job, I had to extend some SuperbaseV4 code. The entire codebase consisted of controls with names such as 'screen1' to 'screen15'. I had to extend this to 30.

    Given two pathways, extending it as it was written, or trying to recode the entire program, I ended up writing a program which I called SpaghettiMaster, that let me GENERATE code like this using wildcards. I think it was written in VB2 or VB3.

    This gave me much more time to play Wolf3D instead cut/pasting and typing in numbers at the end of of each each variable. I still have no regrets...

  • Norman Diamond (unregistered) in reply to Maurits
    Maurits:
    Here's how to count in binary:

    One, ten, eleven, one hundred, one hundred one, one hundred ten, one hundred eleven, one thousand...

    Reading hexadecimal numbers this way runs into the problem that 18 and 1A are homonyms (eighteen vs. "A"-teen). So I suggest reading them by reading the digits (one-eight, one-"A")

    I've always just read the digits when reading a numeral in any base other than 10. Even in binary or octal. (Which 10 is the exception? 10 base 10 of course.)

    The homonym problem arises with Microsoft product keys. Q and 9 are hononyms in Japanese.

  • Norman Diamond (unregistered) in reply to freealloc
    freealloc:
    TRWTF is how bad all the solutions are in the comments also are.
    Yup. You should write code to explain every comment. And your code shouldn't say what the comment is doing, your code should explain why the comment is doing what it's doing.
  • Norman Diamond (unregistered) in reply to Jack 27
    Jack 27:
    Tronic:
    as far as code goes, I like the simple but readable version. var rules[]; for( int i = 0; i<8; i++){ rules[i]=inputInt%(2^i); }
    The operator ^ doesn't really do exponents in javascript does it?
    I hope not.
    Jack 27:
    It's a bitwise XOR in every language I know.
    It did exponents in Basic before Microsoft ever existed. It did pointing in Pascal. IBM used to map ¬ onto ~ for logical not, but later IBM decided to map ¬ onto ^ and I wonder if they use that for logical not. (Yeah, sure that mapping is logical ... NOT.)
  • antekone (unregistered)

    I'm afraid what the bit setting function would look like.

  • foo (unregistered) in reply to Jack 27
    Jack 27:
    Tronic:
    as far as code goes, I like the simple but readable version. var rules[]; for( int i = 0; i<8; i++){ rules[i]=inputInt%(2^i); }

    The operator ^ doesn't really do exponents in javascript does it?

    Just as well as % does bitwise and, I suppose.

  • Zog (unregistered) in reply to Snowrat
    Snowrat:
    rules←inputInt⊤⍨8/2 rules←2|⌽⌊{⍵÷2}\8/inputInt

    The later one is my favourite so far.

    <screams><looks again> APL <screams><runs away>

  • wernsey (unregistered) in reply to Reggie
    Reggie:
    You have a problem. You think "I know, I'll use bits." Now you have 10 problems.

    This was certainly the most entertaining comments thread in a very long time. This shows why TDWTF comments need an upvote button.

    Thanks everyone who participated (even those 1 out of 10 types who don't understand binary).

    I vote for a new conventio where comments can be upvoted.

  • (cs) in reply to Maurits
    Maurits:
    Trying to read binary numbers as their decimal equivalent quickly runs into problems as the numbers get big.

    Here's how to count in binary:

    One, ten, eleven, one hundred, one hundred one, one hundred ten, one hundred eleven, one thousand...

    Reading hexadecimal numbers this way runs into the problem that 18 and 1A are homonyms (eighteen vs. "A"-teen). So I suggest reading them by reading the digits (one-eight, one-"A")

    I couldn't disagree more with your method of counting (out loud) in binary.

    Similar to your binary counting, I know it's really common for software developers to read hexadecimal numbers as if they were decimal: e.g. "0x20" is often read as "hex twenty". But in English, the word twenty has a definite meaning. It refers to the number that comes after nineteen, and it should have the same meaning regardless of the number system it's written in. After all, I'm pretty sure the words for numbers in English predate the Arabic numerals we use today.

    To me, "twenty" can be written 20, XX, 0x14, etc., but not 0x20. IMO, 0x20 should be pronounced "thirty-two" or "hex two-zero", but not "hex twenty".

    After all, you wouldn't pronounce the Roman numeral II as "roman eleven", would you?

    I know I'm in the minority here, as pretty much every other software developer I know would pronounce "0x20" as "hex twenty". I still think it's wrong, and I think people do it because it's easier than saying "hex two-zero."

    [/pedantic rant]

  • QJo (unregistered) in reply to Norman Diamond
    Norman Diamond:
    Maurits:
    Here's how to count in binary:

    One, ten, eleven, one hundred, one hundred one, one hundred ten, one hundred eleven, one thousand...

    Reading hexadecimal numbers this way runs into the problem that 18 and 1A are homonyms (eighteen vs. "A"-teen). So I suggest reading them by reading the digits (one-eight, one-"A")

    I've always just read the digits when reading a numeral in any base other than 10. Even in binary or octal. (Which 10 is the exception? 10 base 10 of course.)

    The homonym problem arises with Microsoft product keys. Q and 9 are hononyms in Japanese.

    I disagree, 18, 1A and 1E are perfectly acceptable as they are. Pronounce them "ayteen", "atteen" and either "eeteen" or "etteen" and if the hearer misunderstands then it's their fault and they need to wash their ears out. Hearing the difference between twenty-A and twenty-eight, and indeed between twenty and twenty-E is merely another challenge of the Third Millennij.

  • djechelon (unregistered)

    Just to save a little memory I would prefer

    long[] rules = new rules[8]

    CAPTCHA: sino "Sì" (yes) or "no"?

  • baka0815 (unregistered)

    There are 10 types of people: those who understand binary and those who don't.

  • L.P.O. (unregistered) in reply to CodeSimian
    CodeSimian:
    I know I'm in the minority here, as pretty much every other software developer I know would pronounce "0x20" as "hex twenty". I still think it's wrong, and I think people do it because it's easier than saying "hex two-zero."

    The idea of language is communication. If "hex twenty" communicates the idea of number 32 written in hexadecimal notation faster than "hex two zero", and if it isn't ambiguous (which it isn't), then it is also not wrong.

    I happily say "ef-thousands" (or its equivalent in my language) rather than "ef zero zero zero", because "ef-thousands" is both faster to say, and it is easier to comprehend how many zeros I meant there to be. In English there would be also "ef triple-zero" but that concept isn't there in my native language.

  • L.P.O. (unregistered) in reply to dtech
    dtech:
    That... or just:
    int size; // E.g. rules.size() or something
    for(int i=0;i<size;i++) {
        rules[i] = inputInt & (1 << (size-i));
    }
    </pre>
    

    (Parentheses added for clarity, not actually necessary)

    With a bit of concentration, you might get that actually right.

    Hint: you probably did not intend to read inputInt bits 8 through 1 into rules[0] through rules[7], but rather bits 7 through 0. Or at least I hope so.

  • (cs)

    I wouldn't normally bother, but three pages of comments without a single correct replacement for the headline WTF is just too much.

    function Rules(inputInt) {
        var bits = 8;
        var rules = [];
        var i = 0;
        var mask = 1 << bits;
        while (mask >>= 1) rules[i++] = inputInt & mask? 1: 0;
        return rules;
    }
    
  • Herr Otto Flick (unregistered) in reply to wernsey
    wernsey:
    Reggie:
    You have a problem. You think "I know, I'll use bits." Now you have 10 problems.

    This was certainly the most entertaining comments thread in a very long time. This shows why TDWTF comments need an upvote button.

    Thanks everyone who participated (even those 1 out of 10 types who don't understand binary).

    I vote for a new conventio where comments can be upvoted.

    Fuck off, this isn't facebook.

  • (cs) in reply to L.P.O.
    L.P.O.:
    CodeSimian:
    I know I'm in the minority here, as pretty much every other software developer I know would pronounce "0x20" as "hex twenty". I still think it's wrong, and I think people do it because it's easier than saying "hex two-zero."

    The idea of language is communication. If "hex twenty" communicates the idea of number 32 written in hexadecimal notation faster than "hex two zero", and if it isn't ambiguous (which it isn't), then it is also not wrong.

    I happily say "ef-thousands" (or its equivalent in my language) rather than "ef zero zero zero", because "ef-thousands" is both faster to say, and it is easier to comprehend how many zeros I meant there to be. In English there would be also "ef triple-zero" but that concept isn't there in my native language.

    Fair enough. However, oftentimes people will drop the "hex" prefix and simply say "twenty", which is ambiguous. Of course, the context of the situation (i.e. reading a hex dump) will normally resolve the ambiguity, but not always. Also, consider that "twenty hex" is arguably more ambigous than "hex twenty", because "twenty hex" could plausibly mean "twenty written in hex" (0x14), or "0x20".

    Going back to what you said about communication, oftentimes people will sacrifice precision for speed and efficiency. Another example is that developers (in conversation) will often assume that "100 KB" means "100,000 bytes", even when the context (size of a file as reported by Windows) clearly states otherwise.

    Of course, natural language will always have ambiguities, so I guess it's silly for me to complain about this specific one.

  • Dallas Edwards (unregistered)

    Oh god.

    Ponies...ponies everywhere...

  • jah (unregistered) in reply to Reggie

    You've got 99 problems, but the bits ain't one.

  • Neil (unregistered) in reply to urza9814
    urza9814:
    Ralph:
    operagost:
    I knew people who actually managed to run OS/2 on 4 MB machines-- but with Win 95, that was an absolute horror.
    Surely that was a typo, and you mean 4 GB, right?

    (My first computer had 8 KB. And we liked it.)

    Uh, my Windows 98 box had only 64MB. And that was pretty decent at the time.

    I suspect you are talking about hard drive space. He meant primary memory. RAM.

    Of course even then, 4GB hard drive space would have been fairly large. Certainly more than the minimum for Win95, which I recall using on systems with only a gig of disk space. With 4GB I think you could even run XP (assuming you didn't plan on installing much else!)

    The reason the clock doesn't show seconds is that the font had to be swapped in to update the time, and that meant that (with only 4MB of RAM) Windows would have been continually swapping.

    4GB on the other hand would have been unusually large amount of hard disk space; at the time, many BIOSes couldn't handle IDE drives of over about 500MB. (Don't ask me whether those are binary or decimal MB, I'm past caring.) SCSI drives were a little better catered for, as you could get up to 4GB or even 8GB boot partition on some controllers. (Once you had booted into Windows NT 3.51 you could of course proceed to access the rest of your SCSI disk.)

  • killian~ (unregistered) in reply to David
    David:
    There are 10 kinds of people in the world, those they get binary, and those that don't.

    ... and those that use trinary.

  • Vermicious Knid (unregistered)

    Bit late to the party. Here is my version (Perl):

    use bigint;
    
    my $inputInt = shift // 0;
    my $mask = ($inputInt >= 1<<32) ? 'Q'
             : ($inputInt >= 1<<16) ? 'L'
             : ($inputInt >= 1<<8 ) ? 'S'
             :                        'C';
    
    my @rules = unpack "(a)*", unpack "b*", pack "$mask", $inputInt;
    

    Of course Remy left the following lines at the end of the code:

    if ( inputInt == 10 ) { /* changed per ticket #33774 */
                       rules[0] = 0;
                       rules[1] = 1;
                       rules[2] = 0;
                       rules[3] = 1;
                       rules[4] = 0;
                       rules[5] = 0;
                       rules[6] = 1;
                       rules[7] = 0;
    }
    if ( inputInt == 23 ) { /* no longer used */
                       rules[0] = 0;
                       rules[1] = 0;
                       rules[2] = 0;
                       rules[3] = 0;
                       rules[4] = 0;
                       rules[5] = 0;
                       rules[6] = 0;
                       rules[7] = 0;
    }
    if ( inputInt == 24 ) { /* combines rules 23 + 24 as per ticket #34451 */
                       rules[0] = 1;
                       rules[1] = 1;
                       rules[2] = 1;
                       rules[3] = 1;
                       rules[4] = 0;
                       rules[5] = 0;
                       rules[6] = 0;
                       rules[7] = 0;
    }
    /* SNIP */ 
    if ( inputInt == 189 ) { /* changed per ticket #44012 */
                       rules[0] = 2;
                       rules[1] = 0;
                       rules[2] = 1;
                       rules[3] = 1;
                       rules[4] = 1;
                       rules[5] = 1;
                       rules[6] = 0;
                       rules[7] = 1;
    }
    
  • David (unregistered) in reply to Ron
    Ron:
    Paid (or otherwise incentivized) by lines of code, I'll bet. This is why you have to reward what you want, not unrelated measures you think might get you closer to what you want.

    Like what? What you want to know is how well something will sell and how much money it will make you, but that can take years and doesn't tell you anything about the effect of any particular employee on the outcome. Figuring out who is doing productive work, who is doing work that will make the customers love the program, who is adding subsystems that no one will care about or use, and who is just plain slacking off is not a trivial problem.

  • Hired Mind (unregistered) in reply to snoofle
    snoofle:
    Not by the line, but I have worked at a place where they tried paying incentives ($25) per bug fix - the idea being that folks would rip through the bug list and make the app perfect.

    What they forgot to do was put in a charge of $50 for every new bug introduced!

    This works pretty well under the right circumstances. At my last job, I was a project manager and could hire anyone I wanted over the internet, so I hired two teams from two different countries: a programming team and a testing team. The two teams never knew about each other so there was never any incentive to game the system.

  • (cs) in reply to SeySayux
    SeySayux:
    template<class CharT>
    bool boolify(CharT c) {
        return c == '1';
    }
    

    template<class OutputIterator, std::size_t N> void to_bit_sequence(std::bitset<N> bits, OutputIterator out) { std::string str = bits.to_string();

    std::transform(str.begin(), str.end(), out, boolify<char>);
    

    }

    int main(int argc, char** argv) { if(argc != 2) return 1;

    std::vector<bool> out;
    
    to_bit_sequence(std::bitset<8>(argv[1]), out.begin());
    std::transform(out.begin(), out.end(), 
            std::ostream_iterator(std::cout, ", "));
    

    }

    There are actually several things wrong with your code.

    1. Primarily you need std::back_inserter(out) to be able to write to your iterator out. out.begin() in your main() is not a valid OutputIterator (because the vector is empty)

    2. vector<bool> is dodgy in the first place. Do not use.

    3. boolify is a template but in your code you are using a std::string iterator so it will never be anything but a char.

    4. The whole thing, i.e. converting to string then back to bool, is the real WTF.

    5. If I still decided to employ to work in my team you'd better change your bracing style. I like readable code without hurting my eyes.

  • (cs) in reply to CodeSimian
    CodeSimian:
    Maurits:
    Trying to read binary numbers as their decimal equivalent quickly runs into problems as the numbers get big.

    Here's how to count in binary:

    One, ten, eleven, one hundred, one hundred one, one hundred ten, one hundred eleven, one thousand...

    Reading hexadecimal numbers this way runs into the problem that 18 and 1A are homonyms (eighteen vs. "A"-teen). So I suggest reading them by reading the digits (one-eight, one-"A")

    I couldn't disagree more with your method of counting (out loud) in binary.

    Similar to your binary counting, I know it's really common for software developers to read hexadecimal numbers as if they were decimal: e.g. "0x20" is often read as "hex twenty". But in English, the word twenty has a definite meaning. It refers to the number that comes after nineteen, and it should have the same meaning regardless of the number system it's written in. After all, I'm pretty sure the words for numbers in English predate the Arabic numerals we use today.

    To me, "twenty" can be written 20, XX, 0x14, etc., but not 0x20. IMO, 0x20 should be pronounced "thirty-two" or "hex two-zero", but not "hex twenty".

    After all, you wouldn't pronounce the Roman numeral II as "roman eleven", would you?

    I know I'm in the minority here, as pretty much every other software developer I know would pronounce "0x20" as "hex twenty". I still think it's wrong, and I think people do it because it's easier than saying "hex two-zero."

    [/pedantic rant]

    If you call A,B,C,D,E and F by their names Alpha, Bravo, Charlie, Delta, Echo and Foxtrot you don't get issue, Alphateen doesn't sound like Eighteen. And TwentyEcho doesn't sound like Twenty.

    However I think hex powers should be given their own unique names. So 0x100 isn't called "one hundred" nor of course do we call it "two hundred and fifty six" or "hex one zero zero" but a proper new name.

    Similarly a naming convention for 0x16 etc. Incidentally it's a WTF in English that the "teen" and "ty" suffixes sound so similar so you can't easily tell between 15 and 50. We'd fix that in our hexadecimal language.

  • (cs) in reply to Herr Otto Flick
    Herr Otto Flick:
    wernsey:
    Reggie:
    You have a problem. You think "I know, I'll use bits." Now you have 10 problems.

    This was certainly the most entertaining comments thread in a very long time. This shows why TDWTF comments need an upvote button.

    Thanks everyone who participated (even those 1 out of 10 types who don't understand binary).

    I vote for a new conventio where comments can be upvoted.

    Fuck off, this isn't facebook.

    It isn't StackOverflow.com either. But upvoting comments dates a lot further back than facebook (where liking is actually a rather annoying feature).

    I think upvoting comments would be cool if that was the way comments were selected to be featured. (I did finally get 2 of my comments featured a few months ago after years of trying).

  • (cs) in reply to AGray
    AGray:
    I'm a C# guy...why couldn't they do something along the lines of... [...]It's not that tough of a concept, though I haven't used flags in months and have probably botched the above code big time. :(
    Translation: Hey, I have no clue what I'm talking about, it's demonstrably too hard for me to grasp, but hey! Let's pretend otherwise.

    Yeah, sure :/

  • Krzysiek (unregistered) in reply to Techpaul
    Techpaul:
    Nah it should XML encoded strings of floats to be really sure he captured EVERY possibility including sign, infinity and of course FileNotFound

    FTFY

  • jay (unregistered) in reply to CodeSimian
    CodeSimian:
    I couldn't disagree more with your method of counting (out loud) in binary.

    Similar to your binary counting, I know it's really common for software developers to read hexadecimal numbers as if they were decimal: e.g. "0x20" is often read as "hex twenty". But in English, the word twenty has a definite meaning. It refers to the number that comes after nineteen, and it should have the same meaning regardless of the number system it's written in. After all, I'm pretty sure the words for numbers in English predate the Arabic numerals we use today.

    To me, "twenty" can be written 20, XX, 0x14, etc., but not 0x20. IMO, 0x20 should be pronounced "thirty-two" or "hex two-zero", but not "hex twenty".

    After all, you wouldn't pronounce the Roman numeral II as "roman eleven", would you?

    I know I'm in the minority here, as pretty much every other software developer I know would pronounce "0x20" as "hex twenty". I still think it's wrong, and I think people do it because it's easier than saying "hex two-zero."

    [/pedantic rant]

    Who says that "twenty" means this many: ||||| ||||| ||||| |||||, and not "the digit two followed by the digit zero"?

    When a French person sees that number of objects and says "vingt", would you say that he is wrong becaue the correct word for that number is "twenty" and not "vingt"? If someone speaking in French may properly call this number of objects "vingt" rather than "twenty" because he is speaking a different language, then by the same reasoning, why may not a person speaking in hex properly call this number of objects "fourteen" rather than "twenty" because he is speaking a different base?

    "0x20 should be pronounced 'thirty-two'". Hmm, let's think about this. Suppose that you and a friend are trying to solve some programming problem. At some point it proves useful for you to read some hex numbers off the screen so he can write them down to check on a calculation or some such.

    So you see, let us say, "x10". You would then say "sixteen". You expect him to write "x10". Then you see "x92B4". You would say "thirty-seven thousand five hundred fifty-six". You then expect him to write "x92B4". And so on through the list.

    This fails the "remotely resembling practical" test.

    Excuse me sir, but you are insane.

  • jay (unregistered) in reply to David
    David:
    I see what you did there.

    There are 10 kinds of people in the world, those they get binary, and those that don't.

    There are two kinds of people in the world: those who divide people into two kinds, and those who don't.

  • (cs) in reply to jay
    jay:
    Who says that "twenty" means this many: ||||| ||||| ||||| |||||, and not "the digit two followed by the digit zero"?

    When a French person sees that number of objects and says "vingt", would you say that he is wrong becaue the correct word for that number is "twenty" and not "vingt"? If someone speaking in French may properly call this number of objects "vingt" rather than "twenty" because he is speaking a different language, then by the same reasoning, why may not a person speaking in hex properly call this number of objects "fourteen" rather than "twenty" because he is speaking a different base?

    "0x20 should be pronounced 'thirty-two'". Hmm, let's think about this. Suppose that you and a friend are trying to solve some programming problem. At some point it proves useful for you to read some hex numbers off the screen so he can write them down to check on a calculation or some such.

    So you see, let us say, "x10". You would then say "sixteen". You expect him to write "x10". Then you see "x92B4". You would say "thirty-seven thousand five hundred fifty-six". You then expect him to write "x92B4". And so on through the list.

    This fails the "remotely resembling practical" test.

    Excuse me sir, but you are insane.

    Look buddy, I admitted it wasn't an entirely reasonable complaint, it's just my personal POV which I recognize is not shared by most. Not sure where you get off calling me "insane".

    'Who says that "twenty" means this many: ||||| ||||| ||||| |||||, and not "the digit two followed by the digit zero"?'

    Look up the etymology of twenty, and ask yourself which came first: the word "twenty", or its decimal representation in Arabic numerals "20". (Hint: Arabic numerals were invented around 500 AD and were only introduced in Europe around the 10th century). Are you telling me "twenty" used to have a different meaning just because people used to write it as "XX" and not "20"? Of course not!

    "vingt" in French and "twenty" in English have the exact same meaning -- they both refer to number you get when you multiply two and ten (by "ten", I mean the total number of fingers, including thumbs, on both hands of a healthy human being.) "Vingt" and "twenty" have always referred to that number, regardless of how it was written down.

    The problem (IMO) is that people usually don't distinguish between a number such as twenty/vingt (meaning this many things: ||||| ||||| ||||| |||||) and its written representation (20, 0x14, XX). Which is why when people see a hex number that looks like "20" -- 0x20 -- they think that they can read it as "twenty". But it isn't.

    Can you explain why roman numerals are always pronounced as the number they represent and not how they're written down?

    In other words "Super Bowl XLVII" is pronounced "Super Bowl Forty-Seven", and not "Super Bowl Exs El Vee Eye Eye".

    So I'm crazy for wanting to pronounce 0x14 as twenty (although I admit this isn't optimal), but people aren't crazy for pronouncing "XLVII" as 47?

    In fact, I think this definition of "twenty" rather proves my point: http://www.thefreedictionary.com/twenty

    1. (Mathematics) the cardinal number that is the product of ten and two; a score See also number [1] 2. (Mathematics) a numeral, 20, XX, etc., representing this number

    Notice that "XX" is an accepted representation of the number "twenty". And so is, I would argue "0x14" and 10100 (binary).

    Now, I agree 100% that it's not practical to say "twenty" when reading "0x14". However, I still say it's wrong to read "0x14" as "fourteen", no matter how many people want to do it, out of laziness. My compromise is to say "hex one four". Just call me crazy.

    Addendum (2012-12-06 15:31): Long story short: I think the word "twenty" (or "vignt") refers to a number, and not a particular representation of it (decimal, roman numerals, binary, hex).

    Addendum (2012-12-06 15:44): I looked it up and Roman numerals were used until about the 14th century. So there was definitely a time when English-speaking people would write "twenty" (or its Old English equivalent) as "XX". Now we write it as "20". The meaning of "twenty" has not changed one bit, because its meaning has nothing to do with how it's written down.

    So for people to now say that "twenty" can mean "0x20" or "020" (octal), or whatever, doesn't sit right with me. Yeah, I know in the real world, language is determined by usage and not definitions, but it's the same kind of mindset ("You know what I meant!") that created the "binary-vs-decimal ambiguity" with units of kilobytes, megabytes, gigabytes, etc.

  • (cs) in reply to jay
    jay:
    Who says that "twenty" means this many: ||||| ||||| ||||| |||||, and not "the digit two followed by the digit zero"?

    When a French person sees that number of objects and says "vingt", would you say that he is wrong becaue the correct word for that number is "twenty" and not "vingt"? If someone speaking in French may properly call this number of objects "vingt" rather than "twenty" because he is speaking a different language, then by the same reasoning, why may not a person speaking in hex properly call this number of objects "fourteen" rather than "twenty" because he is speaking a different base?

    To answer your question more succinctly, when a French person says "vingt" and an English person says "twenty", they are still referring to the same number. No meanings have been altered.

    When a person "speaking in hex" says "fourteen" to mean 0x14, he is talking about a completely different number, and changing the accepted meaning of the word "fourteen", and introducing ambiguity for someone who is missing the context.

    I have actually witnessed conversations which go: Engineer A: You were supposed to write "twenty" to that register. Engineer B: I did. Engineer A: No, I meant "hex twenty". Engineer B: Oops, I wrote "decimal twenty". No wonder it wasn't working.

    But, I'm the crazy one, right?

  • (cs) in reply to jay
    jay:
    "0x20 should be pronounced 'thirty-two'". Hmm, let's think about this. Suppose that you and a friend are trying to solve some programming problem. At some point it proves useful for you to read some hex numbers off the screen so he can write them down to check on a calculation or some such.

    So you see, let us say, "x10". You would then say "sixteen". You expect him to write "x10". Then you see "x92B4". You would say "thirty-seven thousand five hundred fifty-six". You then expect him to write "x92B4". And so on through the list.

    This fails the "remotely resembling practical" test.

    Excuse me sir, but you are insane.

    No, I would say "one zero" and "nine two bee four". I would not say (as some would suggest) "ten" and "nine thousand two hundred BEE four" (the latter really doesn't make any sense to me.)

    Thanks for snipping my quote to make me seem even stupider than I actually am. The original quote was: "0x20 should be pronounced "thirty-two" or "hex two-zero", but not "hex twenty"

    To be fair, "thirty-two" is actually my (distant) second choice, and I'd probably only say it if the actual value is important (as opposed to the way it's displayed/typed.) So my original statement could've been better.

  • (cs) in reply to CodeSimian

    One last post on the subject and I'm out. If non-techie pointed at "0x10" on a computer screen and asked you what it meant, which explanation would make more sense (from an English language and common sense POV)?

    A) "It's another way of writing the number 'sixteen', in a number system called 'hex'. You can pronounce it 'hex one zero'."

    B) "It's 'hex ten', which is another way of writing 'sixteen' or what we would call 'decimal sixteen'. Sometimes people just say 'ten', when it's clear from context what they mean."

    I would prefer A). Obviously most people prefer B), because it's easier for efficient communication (but with more room for ambiguity.)

  • Haseeb (unregistered)

    Instead of such looking short cuts, one is better off, doing it right, by using true bit wise operations.

  • (cs) in reply to Cbuttius
    Cbuttius:
    However I think hex powers should be given their own unique names. So 0x100 isn't called "one hundred" nor of course do we call it "two hundred and fifty six" or "hex one zero zero" but a proper new name.

    Similarly a naming convention for 0x16 etc. Incidentally it's a WTF in English that the "teen" and "ty" suffixes sound so similar so you can't easily tell between 15 and 50. We'd fix that in our hexadecimal language.

    I think this is an awesome idea, actually. Too bad any proposed "spoken hexadecimal language" would never catch on, for the same reason that the proposed "binary prefixes" kibi-, mebi-, gibi-, tebi-, etc. will never be widely adopted.

    I also want to point out to Jay and others, not all developers/engineers have the same standards when it comes to pronouncing hex and binary out loud. I don't know anyone at my company who pronounces binary as though it were decimal: e.g. none of my co-workers read "0100" as "one hundred binary". And I don't have any co-workers who would read "0xF001" as "eff thousand and one". This is despite the fact that they would all pronounce "0x20" as "twenty". Seems that not everyone draws the line for "acceptable pronunciations" at the same place.

    I also think it's interesting that this makes at least two instances where engineers/software developers have taken English words/prefixes that were once unambiguous (kilo-, mega- etc. and all decimal numbers) and made them context-sensitive within our industry. No big deal, right? Tell that to Seagate, who lost a class-action lawsuit over "misleading hard drive capacities".

  • QJo (unregistered) in reply to CodeSimian
    CodeSimian:
    jay:
    Who says that "twenty" means this many: ||||| ||||| ||||| |||||, and not "the digit two followed by the digit zero"?

    When a French person sees that number of objects and says "vingt", would you say that he is wrong becaue the correct word for that number is "twenty" and not "vingt"? If someone speaking in French may properly call this number of objects "vingt" rather than "twenty" because he is speaking a different language, then by the same reasoning, why may not a person speaking in hex properly call this number of objects "fourteen" rather than "twenty" because he is speaking a different base?

    To answer your question more succinctly, when a French person says "vingt" and an English person says "twenty", they are still referring to the same number. No meanings have been altered.

    When a person "speaking in hex" says "fourteen" to mean 0x14, he is talking about a completely different number, and changing the accepted meaning of the word "fourteen", and introducing ambiguity for someone who is missing the context.

    I have actually witnessed conversations which go: Engineer A: You were supposed to write "twenty" to that register. Engineer B: I did. Engineer A: No, I meant "hex twenty". Engineer B: Oops, I wrote "decimal twenty". No wonder it wasn't working.

    But, I'm the crazy one, right?

    The "correct" way to refer to x20 is "hex two zero". Part of our schooling at a very young age was in number bases. The teachers were careful to emphasise that 20 is pronounced "Twenty" only when its base is 10. Otherwise it's "two zero base (n)" where n is whatever base it's in. Technically "x20" should be read "two zero base sixteen" but "hex two zero" beats it on many levels. Similarly "020" would be read as "oct two zero".

    Your mythical engineers in an earlier conv reading out hex numbers to each other will, if they are sensible, read "x2000$ as "hex two zero zero zero" or (given that the context is clear) just "two zero zero zero" - the reason being that once you're in the groove of reading out hex numbers digit by digit, it confuses the hearer to suddenly get a reading for which he needs to mentally jump to a different paradigm. Following "nine ef ay eight" with "two thousand", for example, is as jarring as driving over a bump.

  • (cs) in reply to QJo
    QJo:
    The "correct" way to refer to x20 is "hex two zero". Part of our schooling at a very young age was in number bases. The teachers were careful to emphasise that 20 is pronounced "Twenty" only when its base is 10. Otherwise it's "two zero base (n)" where n is whatever base it's in. Technically "x20" should be read "two zero base sixteen" but "hex two zero" beats it on many levels. Similarly "020" would be read as "oct two zero".

    Your mythical engineers in an earlier conv reading out hex numbers to each other will, if they are sensible, read "x2000$ as "hex two zero zero zero" or (given that the context is clear) just "two zero zero zero" - the reason being that once you're in the groove of reading out hex numbers digit by digit, it confuses the hearer to suddenly get a reading for which he needs to mentally jump to a different paradigm. Following "nine ef ay eight" with "two thousand", for example, is as jarring as driving over a bump.

    Not sure why you're responding to my comment, since I pretty much agree with everything you said. Maybe you should've replied to one of the other comments which said "language is about communication!", "I count binary like this: zero, ten, eleven, one hundred...", "eff thousands is easier to say than eff zero zero zero", or "Who says 'twenty' doesn't actually mean the digit 2 followed by the digit 0" (well it does, but only when "20" is actually meant to represent two times ten. Obviously 0x20 does not represent two times ten.)

    Also, the earlier conv between "mythical" engineers was not my example. That was an example given by someone (Jay) who was trying to tell me how insane I was for thinking that it's incorrect to pronounce "F000" as "eff thousands" (for example.)

    And just in case you were actually referring to the conversation I actually posted about the confusion between two engineers over "decimal 20" and "hex 20", that actually happened at my workplace. More than once.

  • Norman Diamond (unregistered) in reply to CodeSimian
    CodeSimian:
    I also think it's interesting that this makes at least two instances where engineers/software developers have taken English words/prefixes that were once unambiguous (kilo-, mega- etc. and all decimal numbers) and made them context-sensitive within our industry.
    Engineers did it for slang, not expecting the slang to replace the correct scientific and mathematical meaning. And engineers used that slang only for RAM and ROM because of the way those are constructed. 1 gigabit per second didn't used to mean 1,073,741,824 bits per second, once upon a time in a galaxy far far away.
    CodeSimian:
    No big deal, right? Tell that to Seagate, who lost a class-action lawsuit over "misleading hard drive capacities".
    Yes the lawsuit and the court ruling were absurd. No Seagate wasn't the victim. If you picked a manufacturer at random you had a 40% chance of getting it right. (40% chance on Seagate, 40% chance on Western Digital, and 20% chance on Toshiba because they only make notebook drives.)
  • (cs) in reply to Norman Diamond
    Norman Diamond:
    Engineers did it for slang, not expecting the slang to replace the correct scientific and mathematical meaning. And engineers used that slang only for RAM and ROM because of the way those are constructed. 1 gigabit per second didn't used to mean 1,073,741,824 bits per second, once upon a time in a galaxy far far away.
    I realize that. My point is that engineers and developers also say "twenty" as slang for 0x20, for example. And some developers (none that I personally know, but at least one in this thread) even say "one hundred" as slang for 100 (binary). I don't want to look up "twenty" in the dictionary 5 years from now and see:
    twenty ... 3) (Computing) The number(s) represented by the digit "2" followed by "0", regardless of base: e.g. 0x20 (thirty-two, written in hexadecimal), 020 (sixteen, written in octal), etc.

    It wouldn't be such a big deal to me except I've already personally witnessed cases where the ambiguity caused people to waste far more time than it would've taken to just say "hex two zero".

    Norman Diamond:
    Yes the lawsuit and the court ruling were absurd. No Seagate wasn't the victim.
    I don't really care whether the lawsuit and ruling were absurd or not (I'm leaning towards agreeing that they are, though). My point is it all stemmed from an abuse of language in the first place.

    People still complain that "OMG, the disk size Windows reports is different from the disk size specified by the manufacturer!", and I still know at least one IT admin who believes that the difference stems from "unformatted vs formatted capacity". He has no idea about binary vs. decimal prefixes for bits/bytes.

    You say engineers used some slang which was never intended to become mainstream. Well, like I admitted before, meaning comes from usage and not what your teachers tell you or what the dictionary prescribes. I know it's futile to stop the meaning of the word "twenty" from changing or expanding, but that won't stop me from believing that "twenty" should only refer to the number you get when you multiply two by ten.

  • Norman Diamond (unregistered) in reply to CodeSimian
    CodeSimian:
    Norman Diamond:
    Engineers did it for slang, not expecting the slang to replace the correct scientific and mathematical meaning. And engineers used that slang only for RAM and ROM because of the way those are constructed.
    I realize that. My point is that engineers and developers also say "twenty" as slang for 0x20,
    Yeah, but the slang should never have been allowed to get out.

    By the way, even my word "engineers" was too broad. This isn't rocket science. If this were rocket science, engineers would use kilo for 1000 not for 1024.

    CodeSimian:
    Well, like I admitted before, meaning comes from usage and not what your teachers tell you or what the dictionary prescribes. I know it's futile to stop the meaning of the word "twenty" from changing or expanding, but that won't stop me from believing that "twenty" should only refer to the number you get when you multiply two by ten.
    Yeah, twenty is the number of digits a person has. In other words, it varies from person to person. Some have six on each hand, and traditional Japanese gangsters still often have fewer than five.
  • (cs) in reply to jay
    jay:
    So you see, let us say, "x10". You would then say "sixteen". You expect him to write "x10". Then you see "x92B4". You would say "thirty-seven thousand five hundred fifty-six". You then expect him to write "x92B4". And so on through the list.

    This fails the "remotely resembling practical" test.

    Excuse me sir, but you are insane.

    Overheard at work today:

    One engineer to another:
    Let's see, I initialize the ADC with twenty-one...I mean twenty-one hex, so what is that...thirty three.

    This proves two of my points:

    1. It would've been easier, quicker and clearer just to say "hex two one" in the first place
    2. There are times that people actually care about the value of a number ("in decimal"). It isn't stupid to pronounce "0x20" as "thirty-two" when you need to know the value (in English, which would make it easier to think about in decimal). I never meant to imply that you would always pronounce "0x20" as "thirty-two". I just meant that it's one way of saying it that isn't incorrect. Just like 10 binary should be pronounceable as "two", if you want to know the value in English or "decimal".

    Ultimately it doesn't matter, though. People will say whatever they want to say.

    Addendum (2012-12-10 15:07): (I write "in decimal" in quotes, because obviously the value of a number is the same whether you write it as 32, 0x20, XXXII, etc. Of course, when we say "thirty-two", we naturally think of the modern-day decimal Arabic numeral representation "32".)

  • Dick (unregistered) in reply to Reggie

    You mean 8 problems, right?

  • Improv (unregistered) in reply to dtech

    Or if it really has to be 1/0:

    int size; // E.g. rules.size() or something
    
    for(int i=0;i<size;i++) {
        rules[i] = (inputInt>>i) & 1;
    }
    
  • Amy (unregistered) in reply to John
    John:
    So how did they deal with porting this code to a 16-bit machine?

    The pending 64-bit upgrade must be truly impressive ...

    OH GREAT. You just made me spit my coffee. :P

    I'd love to see the code that interprets the rules array.

  • PRTSoft (unregistered)

    I have 1100011 problems, but bitmasks aint 1 of them.

  • Destects (unregistered) in reply to Reggie
    Reggie:
    You have a problem. You think "I know, I'll use bits." Now you have 10 problems.

    I see what you did there!

  • El Oscuro (unregistered)

    I could never actually write code like this, even with copy and paste. Somewhere in the 256 entries, I would make a mistake in one of the ones or zeros, which would make for some rather obscure bugs. So if I had to do this, I would write a shell script to generate it, i.e:

    #!/bin/bash
    for ((i=0; i < 256; i++))
    do
      if [ $i = 0 ]; then
        echo var rules = []\;
        echo if \( inputInt == 0 \) {
      else
        echo } else if \( inputInt == $i \) {
      fi
      # Convert dec to bin
      inputInt=`echo "ibase=10;obase=2;$i" | bc`
      # Format it as an 8 digit binary number
      rules=`printf %.8d $inputInt`
      for ((j=0; j < 8; j++))
      do
        digit=`echo $rules | cut -c$[j+1]`
        echo \ \ rules[$j] = $digit\;
      done
      if [ $i == 255 ]; then
        echo }
      fi
    
    done
    

Leave a comment on “A Bit Misguided”

Log In or post as a guest

Replying to comment #397359:

« Return to Article