06-14-2003, 04:16 AM
The algorithm that I have by Knuth states that it will work up to the year 99999. When I implemented it, I considered that a max of year 9999 would be enough, especially since most date handling programs only handle 4 digit years.
Even though a max of 9999 fits into an integer, I had problems with the arithmetic of the algorithm when testing with larger numbers. I can't remember whether "large" meant over 6000 or over 8000. I just used LONG and the problem went away.
Let's not forget what I mentioned about MOD not working for negative numbers. There are instances when the arithmetic produces an intermediate result that's negative.
For example, if you intend to do the following on the intermediate value called ZZZ:
RESULT = ZZZ MOD 30
If you think ZZZ could be negative, then I sugest taking the MOD as follows:
RESULT = ZZZ-30*INT(ZZZ/30)
Even though a max of 9999 fits into an integer, I had problems with the arithmetic of the algorithm when testing with larger numbers. I can't remember whether "large" meant over 6000 or over 8000. I just used LONG and the problem went away.
Let's not forget what I mentioned about MOD not working for negative numbers. There are instances when the arithmetic produces an intermediate result that's negative.
For example, if you intend to do the following on the intermediate value called ZZZ:
RESULT = ZZZ MOD 30
If you think ZZZ could be negative, then I sugest taking the MOD as follows:
RESULT = ZZZ-30*INT(ZZZ/30)