You probably heard that many Zunes stopped working yesterday:
http://www.sfgate.com/cgi-bin/article.c ... 1525C0.DTL
Zune users wake up to find their music gone
Thursday, January 1, 2009
Zune users, particularly of the 30-GB version, have been waking up to find their music players are part of an apocalyptic meltdown.
-------------------
Here's the zune code that turns the RTC's days since 1980 into years.
Can you find the problem? No fair Googling!
year = ORIGINYEAR; /* = 1980 */
while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}
See you Zune
-
- Forum God/Goddess
- Posts: 7984
- Joined: Sat Jul 24, 2004 2:49 pm
- Location: Slightly outside of Madison
- Contact:
Re: See you Zune
Nope. can't find a problem. Of course I haven't typed anything like that since turbo pascal circa 1995 so... Figures it would be some junior high asinine mistake. Really gonna cost them.
-
- Forum God/Goddess
- Posts: 8804
- Joined: Fri Aug 04, 2006 1:09 pm
- Location: The mystical Far East
- Contact:
Re: See you Zune
I had to Google it to even know what the hell I was looking at. Now that I know what I'm looking at, and after initially still not getting it, I get it.
But since I Googled it, I won't spoil it.
But since I Googled it, I won't spoil it.
-
- Forum God/Goddess
- Posts: 1375
- Joined: Mon Jul 11, 2005 7:49 am
- Location: West side
Re: See you Zune
I'm guessing the > 365 is the problem. If = 365 you would get out of the while loop and hence get an answer a year less than what it should be.
Didn't google it though; is that it?
Didn't google it though; is that it?
-
- Forum God/Goddess
- Posts: 4783
- Joined: Tue Oct 16, 2001 1:21 pm
- Location: Near East Side, Madison
- Contact:
Re: See you Zune
bluethedog wrote:I'm guessing the > 365 is the problem. If = 365 you would get out of the while loop and hence get an answer a year less than what it should be.
Didn't google it though; is that it?
If you indent the code properly it becomes a little more obvious. A leap year has 366 days, not > 366 days. So on leap years if the day remainder is exactly 366 then it will go into an infinite loop because it never reduces the days below 365 to satisfy the exit condition.
-
- Forum God/Goddess
- Posts: 8804
- Joined: Fri Aug 04, 2006 1:09 pm
- Location: The mystical Far East
- Contact:
Re: See you Zune
The source I read said that the if (days > 366) line should read if (days >= 366), but that having the LeapYear line makes the corrected line redundant anyway. What actually happens is that the Zune takes the ifLeapYear line, singles out every leap year, and then fucks up because leap years have 366 days, not 367+ days.
Look forward to the same thing at the end of 2012, Zune owners.
Look forward to the same thing at the end of 2012, Zune owners.
Re: See you Zune
Looks like Zune owners may not have been the only ones.
Return to “Technology & Video Games”
Who is online
Users browsing this forum: No registered users and 2 guests