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

Re: ordered indexing for integers



Hallvard B Furuseth wrote:
Howard Chu writes:
I think you misunderstood.

No, I wrote too briefly.

No matter what you're actually testing for, there is no way you're going to
get a TRUE result from comparing ( signed 32 bit integer > 0x7fffffff ).

Right, and chop <= (max ber_len_t)/2.3333 so the test is a no-op on 32-bit hosts. But on 64-bit hosts, chop can be an 8-byte integer which would require the first byte in the output key to hold 10 bits: inverse sign bit, 8 more bits (one for each chop byte), final sign bit.

If you simply rewrote the test it would eliminate all ambiguity.

>>If it is actually possible for ( chop * 3 > 0x7fffffff ) then this
>> test won't detect that fact. You need to test for
>>	( chop > 0x7fffffff / 3 )

The other point being, it saves a multiply; the division is a compile time constant.
--
-- Howard Chu
Chief Architect, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/