Ah, ok. I still think you can optimize the bad [many same bytes before the first difference] case by using a technique similar to strcmp - compare for equality, and once you found a difference, compare for greater/lesser. The good case is probably not that bad either way (and of course, if the compiler is clever, it will only do ONE compare and three different jump instructions).
Originally Posted by iMalc
That 'splains it, thanks.
Yeah, iMalc is right on about how my bignum class was preforming the comparisons.
So I understand that for all intents and purposes, they're the same.
But... the reason the computer can only process at a certain speed in the first place is due to the speed limit of electrical conduction. So... in theory, one may be zetascopicly faster than the other within the logic gates that the processor uses. Now, I know this is very irrelevent at this point, But I'm just really curious now. :)
Well yeah except that all modern CPUs are synchronous which means that the reading of data from anything is timed with the CPU clock signal, so even if the right transistors are on or off a fraction faster, the value isn't read out until the clock pulse comes along. Thus the two will actually take the same amount of time.
Originally Posted by Yarin
In an asychronous CPU the two cases could actually take different amounts of time, but you're unlikely to be programming for such a device anytime soon.
Understood - thanks for the info.