newnews y2k bug in 2.2.1

Forrest J. Cavalier III mibsoft at mibsoftware.com
Tue Nov 16 03:55:19 UTC 1999


> No, but correctness is.  While it might be folly to think that code is
> going to last until 2100, (at least I sure hope it is folly), I at
> least value the notion that it will still work when 2100 hits.  Doing
> a modulus won't.
> 

After correcting the '>' to '>=', the following
three snippets are strictly equivalent....

We all know C, so we must just be talking about
different things....Maybe I wasn't clear when
I explained which "if" clause to replace with
the modulus.

I am not nit-picking. I reply only because you knew
the intent of the code and maybe the '>=' was not the
right fix?  If the code is supposed to behave differently,
then please explain.

Forrest


----As corrected --------------------------
 century = current->tm_year / 100;

 if (current->tm_year >= 100)
     current->tm_year -= century * 100;

---Easier to read, strictly equivalent------
 century = current->tm_year / 100;

 current->tm_year %= 100;

-------------------------------------------
---Only time test condition is false is when
---century = 0, so we can even drop the test.
---
 century = current->tm_year / 100;

 current->tm_year -= century * 100;


More information about the inn-workers mailing list