Exercise 1: Do your friggin job!
category: general [glöplog]
I don't find it strange that it was a mistake from the beginning anymore. I'm lucky you guys don't code this.
And for the record, I'm _very_ happy I'm not working as a programmer all together :-D
And for the record, I'm _very_ happy I'm not working as a programmer all together :-D
U r geekz, LULZ!!!
common sense, some people dont have it.
what job?
Your job as overpaid embedded developer.
More talk about this in Latest Windows Weekly: http://www.podtrac.com/pts/redirect.mp3/twit.cachefly.net/WW-088.mp3
timebomb bugs/virii are nasty... like timebomb triggers to defeat the average crackers :-)
every podcast except ZINE is _evil_.
Quote:
My thought was similar but I think easier to read and removes the duplicate calls to IsLeapYear():
Code:year = ORIGINYEAR; /* = 1980 */ const int cDaysInYear = IsLeapYear() ? 366 : 365; while (days > cDaysInYear) { days -= cDaysInYear; year++; }
:') .. as if I didn't already know why some developers are worth more than others.
Quote:
I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug:
The world, apparently, is full of Adoks. :(
From 1901 to 2099 (inclusive), there is a leap year every 4 years...
For every software that doesn't need dates in a higher range (I believe the most of the software doesn't need it), why to do the shitty while?
And, even if you need a bigger range, why not deal first with the 100 not 400 divisible cases and then just do the division?
For every software that doesn't need dates in a higher range (I believe the most of the software doesn't need it), why to do the shitty while?
And, even if you need a bigger range, why not deal first with the 100 not 400 divisible cases and then just do the division?
texel:
Simple.
Commercial code is written as fast as possible and is polished until it is good enough to pass acceptance tests and no further. Better code arrives at market later and makes less money. :(
Simple.
Commercial code is written as fast as possible and is polished until it is good enough to pass acceptance tests and no further. Better code arrives at market later and makes less money. :(
Christmas device: How would this work? The loop is iterating through years with both 365 and 366 days, just defining it as a constant once is not sufficient.
Eh, maybe the problem is not that simple after all? ;)
Eh, maybe the problem is not that simple after all? ;)
Oh sorry, my stupid. That was from the thread and I was trying to be nice. In that case: LOL
Calexico: Yeah, IsLeapYear() is supposed to take an argument, and even if the constant wasn't constant, he'd still have the two calls to IsLeapYear() that he says he's getting rid of. It's a very funny thread.
texel: But there's no reason not to get this sort of thing right. People probably won't be using Zunes in 2100, but there's a huge problem with the "it doesn't really matter" attitude, as the Zune Y2k9 bug clearly shows.
Anyway, as one person in that thread demonstrated, all you have to do is a bit of Googling to find out (i.e. if you couldn't work it out yourself) that there's an elegant solution:
texel: But there's no reason not to get this sort of thing right. People probably won't be using Zunes in 2100, but there's a huge problem with the "it doesn't really matter" attitude, as the Zune Y2k9 bug clearly shows.
Anyway, as one person in that thread demonstrated, all you have to do is a bit of Googling to find out (i.e. if you couldn't work it out yourself) that there's an elegant solution:
Code:
const int daysInYear = 365; /* regular year */
const int daysInFourYears = daysInYear * 4 + 1; /* leap day */
const int daysIn100Years = daysInYear * 100 + 24; /* no leap day */
const int daysIn400Years = daysInYear * 400 + 97; /* leap day */
const int daysUntil1980 = 3 * daysIn100Years + 19 * daysInFourYears
+ 3 * daysInYear; /* 379 "years" */
/* [...] */
days += daysUntil1980;
year = 1601; /* year after last 400th year before 1980 */
year += days / daysIn400Years * 400; /* 400-year blocks */
days %= daysIn400Years; /* days since the last 400-year block */
year += days / daysIn100Years * 100; /* centuries */
days %= daysIn100Years; /* days since beginning of century */
year += days / daysInFourYears * 4; /* four-year blocks */
days %= daysInFourYears; /* days since the last leap year */
year += days / daysInYear; /* ordinary years */
days %= daysInYear; /* days since beginning of year */
/*
* At this point, year has the current year, while days has the number of days
* since January 1.
*/
Quote:
const int cDaysInYear = IsLeapYear() ? 366 : 365;
Ouch. I think you get stuff like this, because it looks so simple to fix. It's tempting for everyone with some programming knowledge to chip in and type up some "clever" solution, untested and with not much thinking involved.
In other news: This.
Code:
No, it won't.I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug:
Quote:
The world, apparently, is full of Adoks. :(
But in the end there is only one true Adok.
Yes.