"David T. Ashley" <(EMail Removed)> wrote in message
news:(EMail Removed)...
> Hi,
>
> I'm using a 2's complement machine (and I'm comfortable baking this
> assumption into the code). I've implemented a large number of
> functions on signed integers that are longer than the machine
> supports.
>
> Does the code below for comparison look correct?
>
> I think the right approach is to compare the most significant limb in
> a signed sense then to compare the least significant limbs in an
> unsigned sense. Is that right?
Does your code work? Test with a reasonable mix of positive and negative
numbers (some of which must be equal in the most significant words) to see
if it gives the expected results.
However I might just subtract one number from the other; the sign of the
result will tell you if the relation is < or >=. But you need to check for
all words zero to distinguish > and =.
That assumes you have a reasonably efficient subtract function. (Having
dedicated functions to check each of =,!=,<,<=,>=,>, when a specific
comparison is in mind, might also help to streamline things. Equals/not
equals are particularly easy.)

Bartc
