pouët.net

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
added on the 2009-01-01 17:32:20 by thec thec
U r geekz, LULZ!!!
added on the 2009-01-01 19:54:29 by Optimus Optimus
common sense, some people dont have it.
added on the 2009-01-01 20:15:22 by red red
what job?
added on the 2009-01-02 01:54:21 by rudi rudi
Your job as overpaid embedded developer.
added on the 2009-01-02 21:43:00 by Calexico Calexico
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 :-)
added on the 2009-01-03 00:39:14 by Zest Zest
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. :(
added on the 2009-01-03 02:03:23 by doomdoom doomdoom
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?
added on the 2009-01-03 04:33:45 by texel texel
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. :(
added on the 2009-01-03 09:08:05 by GbND GbND
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? ;)




added on the 2009-01-03 10:02:09 by Calexico Calexico
Oh sorry, my stupid. That was from the thread and I was trying to be nice. In that case: LOL
added on the 2009-01-03 10:03:37 by Calexico Calexico
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:

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. */
added on the 2009-01-03 12:34:47 by doomdoom doomdoom
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.
added on the 2009-01-03 12:44:09 by tomaes tomaes
Code:I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug:
No, it won't.
added on the 2009-01-03 13:06:15 by Adok Adok
Quote:
The world, apparently, is full of Adoks. :(


But in the end there is only one true Adok.
added on the 2009-01-03 13:11:25 by doomdoom doomdoom
Yes.
added on the 2009-01-03 13:13:19 by Adok Adok

login