Jay Reeve wrote: > Robert Purves wrote: >> Comparisons (>, >=, <, <=) of pointer variables in FB are always >> signed. Needing an unsigned '>' comparison, I found it necessary >> to use the clumsy function UnsignedGreaterThan() below, with its >> unpleasant lapse into assembler. >> Can someone supply a more elegant method? > > Here's another entry. More elegant? I don't know. It's definitely > more arcane, but it's only 2 lines, pure FB, and nearly (though not > quite) as fast as your assembler version. > // unsigned comparison: _zTrue if p1 > p2 > local fn UnsignedGreaterThan( p1 as pointer, p2 as pointer ) > end fn = ( p1 > p2 ) xor (( p1 xor p2 ) < 0 ) Nice method. The logical expression is easily generalised to the other relevant comparisons. Signed Unsigned ------ -------- ( p1 < p2 ) ( p1 < p2 ) xor ( ( p1 xor p2 ) < 0 ) ( p1 <= p2 ) ( p1 <= p2 ) xor ( ( p1 xor p2 ) < 0 ) ( p1 >= p2 ) ( p1 >= p2 ) xor ( ( p1 xor p2 ) < 0 ) ( p1 > p2 ) ( p1 > p2 ) xor ( ( p1 xor p2 ) < 0 ) No difference between signed and unsigned comparison: ( p1 == p2 ) ( p1 == p2 ) ( p1 != p2 ) ( p1 != p2 ) Moreover, we don't need the function call, and can simply write: if ( p1 > p2 ) xor ( ( p1 xor p2 ) < 0 ) then whatever... Robert P.