Not totally sure where you are going with this, and it depends on the hardware
The way it all started was.
There's special register in the CPU called Flags
Less than is done by a Subtraction.
Subtraction is done by addition with two's complement representation.
In two's complement negative numbers (bearing in mind overflow) the most significant bit is always 1
So a less than test is Just a - b.
The most significant bit of the result is copied to the N bit of the flags register
and then that is tested.
There's usually a zero bit to test if A = B and an Overflow bit.
A few others as well Carry for istance.
Overflow would be say your number is a signed byte that gives you -128 to + 127 (256 different numbers). so -128 - 1 won't fit and the overflow bit gets set.
There's a load more to this in modern processors, but the basics are still true.
This sort of stuff is a lot easier to pick up in far more basic CPUs than we use now. I learnt it on the Z80 back in 76...
The mouse click one
Is store the "time" of the last click.
Then on next click subtract the above and then compare it with the interval you stored for how fast you had to click for it to be a double click.