• Billy Bob (unregistered) in reply to You're wrong

    Which is a non-sequitur, because he's talking about that being a non-portable assumptions. Not all character sets are ASCII.

  • JimmyVile (unregistered) in reply to Buddy
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • using gets and strtok - evil
    • using atoi, atol, atof without validating input
    • intimidated by qsort to the point of writing their own sort routines
    • non-portable assumptions - 8 bits per byte, two's complement arithmetic, sizeof(short) < sizeof(int) < sizeof(long), sizeof(signed type) == sizeof(unsigned type), 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!)
    • letting system handle memory deallocations (guilty!)
    • not taking advantage of C99 features (guilty!)

    Feel free to add to this list...

    If you have to worry about those portability issues you must be working on some really funky hardware. The relations between shorts/ints etc is somewere in the(a?) C spec. short <= int <= long. Don't know the rest. :P

  • tulcod (unregistered) in reply to You're wrong
    You're wrong:
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • using gets and strtok - evil
    • using atoi, atol, atof without validating input
    • intimidated by qsort to the point of writing their own sort routines
    • non-portable assumptions - 8 bits per byte, two's complement arithmetic, sizeof(short) < sizeof(int) < sizeof(long), sizeof(signed type) == sizeof(unsigned type), 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!)
    • letting system handle memory deallocations (guilty!)
    • not taking advantage of C99 features (guilty!)

    Feel free to add to this list...

    That's true, it's called ASCII.

    ... which is not part of the C specification :_/

  • (cs) in reply to tulcod
    tulcod:
    You're wrong:
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • using gets and strtok - evil
    • using atoi, atol, atof without validating input
    • intimidated by qsort to the point of writing their own sort routines
    • non-portable assumptions - 8 bits per byte, two's complement arithmetic, sizeof(short) < sizeof(int) < sizeof(long), sizeof(signed type) == sizeof(unsigned type), 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!)
    • letting system handle memory deallocations (guilty!)
    • not taking advantage of C99 features (guilty!)

    Feel free to add to this list...

    That's true, it's called ASCII.

    ... which is not part of the C specification :_/

    ASCII silly question, get a silly ANSI, as the saying goes.
  • (cs) in reply to pjt33
    pjt33:
    JJ:
    My brother's original, legal birth certificate lists his day of birth as December 32nd.

    When does he celebrate his birthday? And does he get a lot of hassle when he applies for things like a driver's licence or a passport?

    pink_fairy:
    Anon:
    Which book? You seem to have left that important point out of your incoherent rant.
    (a) I see your troll, and raise you a dwarf. (b) Perhaps you should try a search engine <snip>
    Count the books
    I get asked a direct question by a twit, and I answer that direct question:

    (a) I see your troll, and raise you a dwarf. (b) Perhaps you should try a search engine (c) Here's the specific important point. Go ahead, bore yourself silly ... well, go ahead, bore yourself anyway.

    Then some other twit comes along, quotes (a) and (b), and snips (c).

    I think it's fairly obvious that the underlying problem, which Dawkins tries to address in his reticent way with lecture tours, appearances in the media, half a forest full of books, and his incredibly brave work in the foothills of the Hindu Kush explaining why Mohamed was a raving lunatic and Buddha was an overweight princely upstart, is:

    Self-appointed fundamentalist bigotry. Not "religion," after all; whatever that might be.

    I'm not going to take this preachy smug crap from Christians, and I'm not going to take it from Atheists either.

    Other than learning the simple courtesy of accurate quotation, you might want to brush up on your search engine skills, too. They work on a ranking system, you know. Try typing "popular book Richard Dawkins" into Google and you'll be able to guess the book to which I was referring.

    Yes, it's "The Selfish Meme," victim of a tragic type-setting error at the publishers... And of course we're both assuming that Idiot Number 1 was not already aware of the book in question -- which is a disingenuous proposition, to say the least.

  • A fan (unregistered)

    Speaking of which, I liked that book by Isaac Asimov. You know which book I mean, look it up.

  • (cs) in reply to A fan
    A fan:
    Speaking of which, I liked that book by Isaac Asimov. You know which book I mean, look it up.
    I did, too. And, oddly enough, I know exactly the one you mean.

    Way to go to miss the point, anonymous boy. Or maybe, as a distinguished co-worker of mine used to remark, "I don't like to read. It just hurts my eyes."

  • JimmyVile (unregistered) in reply to pink_fairy
    pink_fairy:
    pjt33:
    JJ:
    My brother's original, legal birth certificate lists his day of birth as December 32nd.

    When does he celebrate his birthday? And does he get a lot of hassle when he applies for things like a driver's licence or a passport?

    pink_fairy:
    Anon:
    Which book? You seem to have left that important point out of your incoherent rant.
    (a) I see your troll, and raise you a dwarf. (b) Perhaps you should try a search engine <snip>
    Count the books
    I get asked a direct question by a twit, and I answer that direct question:

    (a) I see your troll, and raise you a dwarf. (b) Perhaps you should try a search engine (c) Here's the specific important point. Go ahead, bore yourself silly ... well, go ahead, bore yourself anyway.

    Then some other twit comes along, quotes (a) and (b), and snips (c).

    I think it's fairly obvious that the underlying problem, which Dawkins tries to address in his reticent way with lecture tours, appearances in the media, half a forest full of books, and his incredibly brave work in the foothills of the Hindu Kush explaining why Mohamed was a raving lunatic and Buddha was an overweight princely upstart, is:

    Self-appointed fundamentalist bigotry. Not "religion," after all; whatever that might be.

    I'm not going to take this preachy smug crap from Christians, and I'm not going to take it from Atheists either.

    Other than learning the simple courtesy of accurate quotation, you might want to brush up on your search engine skills, too. They work on a ranking system, you know. Try typing "popular book Richard Dawkins" into Google and you'll be able to guess the book to which I was referring.

    Yes, it's "The Selfish Meme," victim of a tragic type-setting error at the publishers... And of course we're both assuming that Idiot Number 1 was not already aware of the book in question -- which is a disingenuous proposition, to say the least.

    Wow. Just... wow. I think I just ground off a few mm of my teeth while reading your post. I never read a post that made me instantly dislike someone that much. Good day to you sir.

  • (cs)

    This looks like a Y2K bug check. I've seen it done before. Get the end of this year, add one and get the new year. If the computer suffers the Y2K bug in that particular piece of software (or maybe the BIOS), and it happens to be 31/12/1999, the new year might be 2000, or it might be 100, or 00. Subtracting one will obvious then give a different result, thus confirming Y2K non-compliance.

  • slebetman (unregistered) in reply to Chelloveck
    Chelloveck:
    I've come across quite a few C compilers for oddball processors which don't support //. Haven't yet found one where a char is anything other than 8 bits, though.
    I've seen a DSP (I think Texas Instruments) where char is 32 bits, short is 32 bits and int is 32 bits. And the compiler is perfectly ANSI and ISO compliant.
  • georgie (unregistered)

    TRWTF: it took us half a day to figure it out.

    Actually, this is a pretty good way to deal with issues that may arise from changing locale. With the check that you propose, you'd never get to the end of the year in Europe. Of course, you can hope they'd be too busy celebrating the new year and your program would never run on the 31/12/iYear

    George

  • (cs) in reply to Jay
    Jay:
    They don't want to hire someone who is totally opposed to the goals of their organization and thinks that anyone who holds their beliefs are a bunch of idiots, no matter how good he is at the job. If Fred got a job as a programmer for a religious organization, surely they would be justified in worrying that at best he would be unethusiastic, and at worst that he might deliberately sabotague them. Not necessarily, of course. He might view his job purely as a set of technical challenges. But it would make me nervous if I was the boss.
    And that is what gets everyone's backs up. The smugly complacent assumption that everyone who is part of your little clique is somehow magically guaranteed to be trustworthy, and everyone who doesn't share your belief system is somehow intrinsically wicked, for not being like you. People do not like to feel unjustly accused by a nasty, paranoid, small-minded attitude of baseless mistrust and suspicion. It is an utter non-sequitur that someone can't do a professional job for an organisation whose goals they don't themselves share, as it is that someone who shares your beliefs will necessarily not betray you.
    Oh yes, we want to ensure a good Christian upbringing to all our young charges, which is why we only recruit retired Catholic priests here at RC Day Nursery.
    A facetious and stupid example, of course, but the point remains: just because someone is in the same group as you does not mean that your interests and theirs are automatically aligned, and therefore you are not actually protecting the aims of your organisation by recruiting them. It may be well-but-mistakenly intentioned, but it comes across as overweening self-regard.
  • (cs) in reply to pink_fairy
    pink_fairy:
    Yes, it's "The Selfish Meme," victim of a tragic type-setting error at the publishers...
    By seizing on the opportunity for sarcasm, you've missed an opportunity to make clear what your point actually is. I've been following and I can't tell if you simply hate Dawkins for being smug/preachy/patronising, or if you have a serious philosophical or logical objection to the concept of memes as an analogy/metaphor/model?
  • Anonymous (unregistered) in reply to DaveK

    This is definitely not a WTF. The purpose of the bSkipYearCheck variable isn't clear, and there should be a comment explaining it, but the actual logic seems to say "Is tomorrow next year?" which is totally reasonable. If you already have a bunch of code that knows how many months are in a year and how many days are in each month then why not actually use that code instead of hard-coding extra logic like (month=12 And day=31) that bypasses it?

    Also, considering all of the exceptions involved in calendar logic, if this article had claimed that December only has 30 days, or has 30 days sometimes, I would not have spotted that as an obvious falsehood. If I had to write code to do this, it would have been more time-consuming to make it check a specific day (because I'd have to first look up online how many days are in December and verify with multiple sources that it's really always 31 with no exceptions) than to write it like this. And in the end it would be harder for other people to verify because they would probably have to go through the same process to make sure a hard-coded 12/31 is always correct. Just because a magic number seems obvious to you at the time doesn't mean everyone who will look at your code will trust it as much as you did.

  • And the rat is... (unregistered) in reply to java.lang.Chris;
    java.lang.Chris;:
    VB programmers criticising a C programmer - and with just cause. I never thought I'd see that happen.
    Maybe they shouldn't have hired an orangutang.
  • (cs) in reply to codemanque
    codemanque:
    This looks like a Y2K bug check. I've seen it done before. Get the end of this year, add one and get the new year. If the computer suffers the Y2K bug in that particular piece of software (or maybe the BIOS), and it happens to be 31/12/1999, the new year might be 2000, or it might be 100, or 00. Subtracting one will obvious then give a different result, thus confirming Y2K non-compliance.
    No, sorry, checking form Y2K compliance isn't always that easy. If the next year is 100, as in your example, subtracting 1 will result in 99, but that won't be flagged as an error, because the current year will be 99!
  • And the rat is... (unregistered) in reply to CaptainSmartass
    CaptainSmartass:
    Sounds like something a bored programmer would come up with, not really a WTF.

    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?

    Maybe they want someone whose prayers they think will be heard?

  • (cs) in reply to JimmyVile
    JimmyVile:
    pink_fairy:
    <snip apparently contentious Dawkins stuff, available above/>

    Wow. Just... wow. I think I just ground off a few mm of my teeth while reading your post. I never read a post that made me instantly dislike someone that much. Good day to you sir.

    Well, you know what Spike Milligan says -- "I took an instant dislike to the man. It saved time."

    Oddly enough, I don't dislike you. In fact, I'm pretty sure I've never met you.

    Hello, gorgeous!

  • (cs) in reply to codemanque
    codemanque:
    This looks like a Y2K bug check. I've seen it done before. Get the end of this year, add one and get the new year. If the computer suffers the Y2K bug in that particular piece of software (or maybe the BIOS), and it happens to be 31/12/1999, the new year might be 2000, or it might be 100, or 00. Subtracting one will obvious then give a different result, thus confirming Y2K non-compliance.
    I hate to say it, but this is a horribly plausible explanation.

    Not that anybody cares, and not that TDWTF is anything to do with decent analysis rather than idiots chucking out "I'd have done it this way" reams of code, and anyway, it's far too late in the thread for anybody to care.

    But still. This is horribly plausible.

  • (cs) in reply to DaveK
    DaveK:
    pink_fairy:
    Yes, it's "The Selfish Meme," victim of a tragic type-setting error at the publishers...
    By seizing on the opportunity for sarcasm, you've missed an opportunity to make clear what your point actually is. I've been following and I can't tell if you simply hate Dawkins for being smug/preachy/patronising, or if you have a serious philosophical or logical objection to the concept of memes as an analogy/metaphor/model?
    Yeah, I'm prone to that seizing thing. Also, I hate to be picky.

    I don't hate Dawkins. That would be absurd. The man's an Oxford Don, for God's sake -- and not all of them are perverted, drunken sots. (Well, it's been twenty five years. Maybe some of them. Not all.)

    To clarify, I hereby accuse Dawkins of being "smug/preachy/patronising..."

    ... but I have no serious philosophical or logical objection to the concept of memes as an analogy/metaphor/model.

    How could I? Is the sky blue/falling down/fish?

    Analogies, by their very definition, are meant to lead somewhere. I don't see this one leading anywhere. In the course of checking facts (yes, I do that now and again. Once I was an academic historian. Now I'm stuck on a site full of ignorant children who can't be bothered and use selective quotation -- not you; a reference to the twits above) I looked at the Memetics entry:

    "The memetics movement split almost immediately into two."

    I'd encourage you to read the rest of it. Anti-religious rants good it is for, young Jedi, but a parallel advance in the "social sciences" to quantum mechanics it very definitely not is.

    Not nearly.

    Addendum (2009-04-04 18:18): PS "Victim of a tragic type-setting error" was a joke, not sarcasm. Jokes are easily distinguished from sarcasm by causing strange and inadvertent hiccoughing noises for those that read or listen to them ... which sarcasm fails to achieve, generally.

    I'll go back to the drawing board, but I'll be here all night. Have you seen my rubber chicken? She used to be my mother-in-law, until I bought her Ludwig's Tractatus Logico-Philosophicus. Have you heard the one about the rabbit and the ironmonger? ed: this one's actually funny, for a change. Look it up, sub?

    OK. Here it is. Serious point. I'm distressed by unthinking absolutes, and that's what I see here. I'm bored by Dawkins, but it's fine by me if other people get their rocks off reading a (fairly dull) book.

    Just don't buy it on a trip to California to save your ex-girlfriend and her twelve year old daughter from the results of an amphetamine addiction, which is what I did.

    I think I'm justified, here, in the following outrageous and entirely personal claim:

    Dawkins is a fucking idiot. And so is anybody who parrots his words without at least a modicum of thought first.

  • Duke of New York (unregistered) in reply to You're wrong
    Buddy:
    Common crimes of C developers...
    It ain't a crime if everyone's doing it.
  • Roman (unregistered)

    This is not Future-Proofing. This is Maybe-They-Do-Not-Use-Gregorian-Calendar-Proofing.

  • Murphy (unregistered) in reply to Ken B
    Ken B:
    In fact, C defined CHAR_BITS specifically because it may be more than 8.

    murphy@seasonsend:~ $ grep -R CHAR_BITS /usr/include/ murphy@seasonsend:~

    You were saying?

  • A (unregistered) in reply to Pim
    Pim:
    The real WTF is that Jake writes "ease of coding in VB".

    Jake, here.

    unsigned int x; if (x>=0xC0000000) {...}

    Translate that into VB please. With ease of coding of course!

    if (Math.Random < 0.5) { ... }

    You never initialized x. ;)

  • (cs) in reply to Chelloveck
    Chelloveck:
    Kermos:
    But seriously, I've yet to come across a C compiler that doesn't support //

    You've obviously not worked in embedded systems. I've come across quite a few C compilers for oddball processors which don't support //. Haven't yet found one where a char is anything other than 8 bits, though.

    Actually quite the contrary, I quite frequently work with embedded systems. Generally though for me this means an ARM based processor with GCC. No problems there. About the only embedded processor I can think of where I haven't used GCC would be a PIC. Can't quite recall if Microchip's compiler handles // or not...been too long. I want to say yes though.

  • sota (unregistered) in reply to Buddy
    Buddy:
    Bobbo:
    The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".

    Come on Alex, is a pluralisation check that complicated??

    Technically, it's a non-singular check (zero being neither plural nor singular):

    0 comments 1 comment 2 comments 3 comments ... 10¹ºº comments etc.

    Some things just seem more plural than others.

    Oh, and does anyone have a link to the thread with all those comments? Given the tendencies laws of internet forums, I'm curious what that eventually devolved into.

  • Duke of New York (unregistered) in reply to JimmyVile
    JimmyVile:
    Wow. Just... wow. I think I just ground off a few mm of my teeth while reading your post. I never read a post that made me instantly dislike someone that much. Good day to you sir.
    While I don't approve of off-topic discussions, it always warms my heart to see someone twist a Dawkins groupie's shorts.
  • (cs) in reply to pink_fairy
    pink_fairy:
    words words words IM SO SMART GUYS words words words
    I don't think I have ever been moved to such a strong visceral dislike of someone over the internet in my life, no matter how right or wrong you are. You're just damn obnoxious. Also, you take every opportunity to WHAT THE HELL WHY IS THERE A MONKEY IN MY KITCHEN SINK go off on some tangential rant for no reason at all. Kindly stuff it.
  • AR (unregistered) in reply to CaptainSmartass

    Unless you are the one paying him how is it any of your business?

  • (cs) in reply to kastein
    kastein:
    pink_fairy:
    words words words IM SO SMART GUYS words words words
    I don't think I have ever been moved to such a strong visceral dislike of someone over the internet in my life, no matter how right or wrong you are. You're just damn obnoxious. Also, you take every opportunity to WHAT THE HELL WHY IS THERE A MONKEY IN MY KITCHEN SINK go off on some tangential rant for no reason at all. Kindly stuff it.
    Well, it seems to be working, then.
  • Sherif (unregistered)

    It's not future proof, but it's culture proof.

    Not all culture use the Gregorian Calendar. Some Arab countries use Hijry calendar where the the number of days in a month may vary from year to year.

    The hebrew calendar leap year has 13 months.

    Checking for 12/31 will work only in Gregorian calendar.

  • ML (unregistered) in reply to Anon
    Anon:
    CaptainSmartass:
    Sounds like something a bored programmer would come up with, not really a WTF.

    TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?

    Is that even legal? I guess they are not an equal opportunity employer.

    It's for the International Justice Mission, a religious organization. As such, they are exempt from Title VII's prohibition of religious discrimination. I personally feel that they are abusing the spirit of their Title VII exemption in that having a non-christian systems engineer, mechanic, or janitor does not interfere with their religious mission.

  • ML (unregistered) in reply to avflinsch
    avflinsch:
    in Rexx, forever is built in

    do forever /* whatever */ end

    Shouldn't it be:

    do forever /* whatever */ doesntend

  • (cs) in reply to jeremypnet
    jeremypnet:
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • non-portable assumptions ... sizeof(int) < sizeof(long)
    You must be so new to C programming that you've only ever programmed on 64 bit platforms.

    (Default compiler settings on OS X.5 are 32 bit)

    Not really, on 16-bit systems it would also be true -- int is 16 bits and long is 32.

  • Anonymous JboPre (unregistered) in reply to Just Sayin
    Just Sayin:
    Long before the sun grows cold, we could develop some common sense and restructure the calendar as 13 months of 28 days each.

    I'd prefer to develop the engineering skills needed to modify the Earth's rotation and revolution slightly so that they're exact multiples of each other and of some convenient integer. Why should we put up with the sloppy approximations nature gave us? (Aligning it to the seven-day week as well will be trickier....)

  • Anonymous Skeptic (unregistered) in reply to Pim
    Pim:
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • using gets and strtok - evil
    • using atoi, atol, atof without validating input
    • intimidated by qsort to the point of writing their own sort routines
    • non-portable assumptions - 8 bits per byte, two's complement arithmetic, sizeof(short) < sizeof(int) < sizeof(long), sizeof(signed type) == sizeof(unsigned type), 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!)
    • letting system handle memory deallocations (guilty!)
    • not taking advantage of C99 features (guilty!)

    Feel free to add to this list...

    There are 8 bits in an byte, silly.

    has C ever been supported on a 12-bit byte machine (e.g. pdp-8)? i'm sure there have been mainframes and other such things out there that had minimal addressable units of 16 bits.

  • Anonymous Skeptic (unregistered) in reply to Zerbs
    Zerbs:
    Bobbo:
    The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".

    Come on Alex, is a pluralisation check that complicated??

    This isn't that annoying is it? Reminds me of when I used to work at a (U.S.) company that used Lotus Notes as their e-mail, and had an office in Austrailia. A read receipt from an e-mail we sent there in the afternoon would often come back: "Your message has been read tomorrow at 8:03 AM"

    mac's "friendly" date format (in Mail.app, the Finder, etc.) will say "tomorrow" when appropriate.

  • Anonymous Acker (unregistered) in reply to Murphy
    Murphy:
    Ken B:
    In fact, C defined CHAR_BITS specifically because it may be more than 8.

    murphy@seasonsend:~ $ grep -R CHAR_BITS /usr/include/ murphy@seasonsend:~

    You were saying?

    trwtf is that you're not using ack

  • Bob (unregistered) in reply to Anonymous Acker
    Anonymous Acker:
    Murphy:
    Ken B:
    In fact, C defined CHAR_BITS specifically because it may be more than 8.

    murphy@seasonsend:~ $ grep -R CHAR_BITS /usr/include/ murphy@seasonsend:~

    You were saying?

    trwtf is that you're not using ack

    WTF is ack?

    Also, CHAR_BIT is defined, although CHAR_BITS is not.

    limits.h:#define CHAR_BIT       8
    
  • (cs) in reply to Badastronomy
    Badastronomy:
    Actually since the Earth's rotation is slowing there will be fewer days in the year which might cancel out the longer year caused by the Earth getting farther away from a reduced mass red giant sun.

    That reduced rotational speed is however compensated for by the earth drifting away from the sun, causing its orbit to grow longer. Whether those effects will combine to yield more or less days before this system goes offline remains to be seen.

  • Jose Correia (unregistered) in reply to ContraCorners

    Re: Ethiopia has such a calendar now. In fact, their Ministry of Culutre and Tourism uses the slogan "13 Months of Sushshine."

    Well the 13 month calendar is what the Mayans advocated long time ago, in fact it was the Catholic Church that came up with Gregorian Calendar that doesn't ""go with the flow"... maybe one day we will learn to go back to balance.

  • (cs) in reply to Anonymous JboPre
    Anonymous JboPre:
    (Aligning it to the seven-day week as well will be trickier....)
    Why do we need a seven day week?

    That's a religious thing as well.

    NB - Not just Pentateuch based religions, but others as well - seven days a week is probably because (a) there are seven visible heavenly bodies which move across the sky (see the names of the days of the week which are based on their names), and (b) the phases of the moon last seven days. (You can juggle with cause/effect to please whatever your religious beliefs are:) )

  • Oresama (unregistered)

    The code is bug-free, simple and easy to understand. As others said before me, the WTF is really that so many people seem to think this is a WTF.

  • Int God (unregistered)

    The real WTF is why spend a half a day on this piece of code. And why is the programmer allowed to spend a decade on it ?

    That's the real WTF of this article.

  • (cs)

    I actually think this code is better than the alternative 'check for December 31st' method.

    If it was checking for Christmas Day by adding 7 onto the day and checking if the year was the same, then that would be a WTF, but this test is checking 'Is this the last day of the year?', NOT 'Is today the 31st of December?'.

    If code is meant to be self documenting, then it seems that the original code said that the test was for the last day of the year.

    If it checked for 31st December, then you might wonder 'why that particular day?'. That's introducing a couple of 'magic numbers' which aren't necessary. A check for 31st December MAY be a check for the last day of the year, or it may be the boss's birthday, or it may be the day to watch out for swans, or the anniversary of the chartering of the British East India Company, or whatever.

  • Zemyla (unregistered) in reply to Buddy
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • non-portable assumptions - ...two's complement arithmetic...
    The C standard guarantees two's complement arithmetic. Otherwise, bitwise operators and arithmetic operators would be completely unusable together.

    For the record, CHAR_BIT is guaranteed to be >= 8.

  • Buddy (unregistered) in reply to Zemyla
    Zemyla:
    Buddy:
    C developers are not immune to criticism.

    Common crimes of C developers (not including common mistakes like using = for ==):

    • non-portable assumptions - ...two's complement arithmetic...
    The C standard guarantees two's complement arithmetic. Otherwise, bitwise operators and arithmetic operators would be completely unusable together.

    For the record, CHAR_BIT is guaranteed to be >= 8.

    Not really an official source, but too early in the AM...

    http://stackoverflow.com/questions/653289/bit-shifts-in-c

    I don't think anyone would be masochistic enough (any more?) to design using BCD as an internal native representation!

  • (cs) in reply to Int God
    Int God:
    The real WTF is why spend a half a day on this piece of code. And why is the programmer allowed to spend a decade on it ?
    Because it's so horribly difficult to test! If you don't get it right the first time, you've got to wait a whole year before you can test under the same circumstances again!
  • JJ (unregistered) in reply to pjt33
    pjt33:
    JJ:
    My brother's original, legal birth certificate lists his day of birth as December 32nd.

    When does he celebrate his birthday? And does he get a lot of hassle when he applies for things like a driver's licence or a passport?

    The odd thing is that his birthday is actually the 30th, so I don't see how it was just a miskey unless they were using the number pad on their computer.

    We celebrate on the 30th, and he just had to get his birth certificate corrected, so there hasn't been any hassle that I know of.

  • Anonymous Acker (unregistered) in reply to Bob
    Bob:
    Anonymous Acker:
    Murphy:
    Ken B:
    In fact, C defined CHAR_BITS specifically because it may be more than 8.

    murphy@seasonsend:~ $ grep -R CHAR_BITS /usr/include/ murphy@seasonsend:~

    You were saying?

    trwtf is that you're not using ack

    WTF is ack?

    ack is better than grep

Leave a comment on “Foolproof Future-Proofing”

Log In or post as a guest

Replying to comment #:

« Return to Article