0

I'm sorting tuples of 16+16 bits as 32bit integers with SSE2. There are only signed integer instructions for compare and min/max. I don't have a problem with the order for the higher part as its just a hash. But entries with negative hashes will be sorted backwards (right?) Possible but not great solutions could be:

  • Zero the higher bit for hashes, losing precision (not great)
  • Convert the position to negative if the higher bit of the hash is set, and convert it back after sorting.

Is there a better way?

alecco
  • 2,914
  • 1
  • 28
  • 37

1 Answers1

1

Just subtract 0x80000000 from your 32 bit values, use signed operations, then add back the 0x80000000 afterwards.

Paul R
  • 208,748
  • 37
  • 389
  • 560