You have to apply some powerful magic, called "maths".
If I were you, I'd not read the following of that message, it's much too
esoteric.
The first time is characterized with this system of equations:
t₁ = 65536×h₁ + l₁
0 ≤ h₁ < 65536
0 ≤ l₁ < 65536
The second time with this similar system:
t₂ = 65536×h₂ + l₂
0 ≤ h₂ < 65536
0 ≤ l₂ < 65536
Comparing those times is adding this equation to the above system:
t₁ < t₂
t₁ = 65536×h₁ + l₁
0 ≤ h₁ < 65536
0 ≤ l₁ < 65536
t₂ = 65536×h₂ + l₂
0 ≤ h₂ < 65536
0 ≤ l₂ < 65536
So we have to solve a system of equations with 3 variables and 7
equations.
I told you do not read further!
t₁ < t₂ ∧ t₁ = 65536×h₁ + l₁ ∧ t₂ = 65536×h₂ + l₂
⇔ 65536×h₁+l₁ < 65536×h₂+l₂ ∧ t₁ = 65536×h₁ + l₁ ∧ t₂ = 65536×h₂ + l₂
Now, notice that:
∀n, 65536×(n+1) + 0 > 65536×n + 65535
⇔ ∀n, 65536×n + 65536 > 65536×n + 65535
⇔ ∀n, 65536 > 65535
⇔ true
Similarly,
∀n,p n > p ⇒ 65536×n + 0 > 65536×p + 65535
⇔ ∀n,p n > p ⇒ 65536×(n-p+p) > 65536×p + 65535
⇔ ∀n,p n > p ⇒ 65536×(n-p)+65536×p > 65536×p + 65535
⇔ ∀n,p n > p ⇒ 65536×(n-p) > 65535
⇔ ∀n,p n > p ⇒ 65536×(n-p) ≥ 65536 > 65535
⇔ ∀n,p n > p ⇒ true
⇔ true
Therefore, if h₂ > h₁ then t₂ > t₁
and if h₁ > h₂ then t₁ > t₂
Now, if h₂ = h₁, then
t₁ < t₂ ∧ t₁ = 65536×h₁ + l₁ ∧ t₂ = 65536×h₂ + l₂ ∧ h₁ = h₂
⇔ 65536×h₁+l₁ < 65536×h₁+l₂ ∧ t₁ = 65536×h₁ + l₁
∧ t₂ = 65536×h₂ + l₂ ∧ h₁ = h₂
⇔ l₁ < l₂ ∧ t₁ = 65536×h₁ + l₁ ∧ t₂ = 65536×h₂ + l₂ ∧ h₁ = h₂
Therefore, if h₂ > h₁ then t₂ > t₁
if h₁ > h₂ then t₁ > t₂
if h₁ = h₂ then if l₁ < l₂ then t₁ < t₂
if l₁ > l₂ then t₁ > t₂
if l₁ = l₂ then t₁ = t₂
Does this look like an "algorithms"? I told you, dark magic here!
(defun time-lessp (t1 t2)
"Returns whether t1<t2
t1 and t2 are lists of two integers. The first integer has the
high-order 16 bits of time, the second has the low 16 bits."
(destructuring-bind (h1 l1) t1
(destructuring-bind (h2 l2) t2
(cond
((< h1 h2) t)
((> h1 h2) nil)
(t (cond ((< l1 l2) t)
(t nil)))))))
--
__Pascal Bourguignon__
http://www.informatimago.com/
A bad day in () is better than a good day in {}.