0

If you look at this answer, the author manages to create a compact comparison algorithm for 2 integer bignums, stored in 2 SSE registers. I am not following it too well :)

What I did so far:

if l = a < b = {a[i] < b[i] ? ~0 : 0} and

e = a == b = {a[i] == b[i] ? ~0 : 0}

then a < b == l[3] v e[3]l[2] v e[3]e[2]l[1] v e[3]e[2]e[1]l[0]

But this does not seem to be what the author is doing. What am I missing? What need is there for a greater than comparison?

Community
  • 1
  • 1
user1095108
  • 14,119
  • 9
  • 58
  • 116

1 Answers1

0

I've overlooked than the answer was not generic, but limited to 64-bit bignums, composed out of 32-bit elements. If you have 2 64-bit vectors a = {a0, a1}, b = {b0, b1}, then the program calculates:

a < b = ((a1 < b1) | (a0 < b0)) & ~(a1 > b1)

In my question I was aiming at arbitrarily long BigNums, implemented with SSE/AVX registers.

user1095108
  • 14,119
  • 9
  • 58
  • 116