[math-fun] Zune doesn't zzzing any more
[Reminds me of the "phase of the moon" bug ... http://www.ccil.org/jargon/jargon_31.html] comp.risks had more info on the Zune calendar freeze bug:
The issue is an infinite loop:
while (days > 365) { if (IsLeapYear(year)) { if (days > 366) { days -= 366; year += 1; } } else { days -= 365; year += 1; } }
Under normal circumstances, this works just fine. The function keeps subtracting either 365 or 366 until it gets down to less than a year's worth of days, which it then turns into the month and day of month. Thing is, in the case of the last day of a leap year, it keeps going until it hits 366. Thanks to the if (days > 366), it stops subtracting anything if the loop happens to be on a leap year. But 366 is too large to break out of the main loop, meaning that the Zune keeps looping forever and doesn't do anything else.
participants (1)
-
Henry Baker