[futurebasic] Re: [FB] Signed and unsigned comparison

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2007 : Group Archive : Group : All Groups

From: Jay Reeve <jayreeve@...>
Date: Sun, 13 May 2007 02:17:56 -0500
On May 12, 2007, at 5:14 AM, 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?
>
> Robert P.

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.

   e-e
   =J= a  y
    "
// unsigned comparison: _zTrue if p1 > p2
local fn UnsignedGreaterThan( p1 as pointer, p2 as pointer )
end fn = ( p1 > p2 ) xor (( p1 xor p2 ) < 0 )