[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ordered indexing for integers

Also overflow gives wrong ordering:
    value 0x100000000: index 0480000000
    value  0x80000000: index 0580800000
I'm too tired to figure out what the code does at overflow now, and
maybe I misunderstood the discussion earlier, but it should give the
right _ordering_ for overflow even if it can't make a very exact index.

I wrote:
> To get the correct ordering, use normal (fully sign-extended) two's
> complement but with the sign bit inversed.  (Same as value + max
> positive value + 1)

Actually, looking at lutil_str2bin() one's complement would be easier:-)
And maybe it needs to turn '-0' into '0'?  I think that's invalid LDAP
Integer syntax so it doesn't matter in that context, but still.