Thread

  1. XOR operator.

    Joshua Moore-Oliva <josh@chatgris.com> — 2003-03-29T02:57:04Z

    Does postgresql support the xor operator?
    
    Josh.
    
    
    
  2. Re: XOR operator.

    Stephan Szabo <sszabo@megazone23.bigpanda.com> — 2003-03-29T03:54:52Z

    On Fri, 28 Mar 2003, Joshua Moore-Oliva wrote:
    
    > Does postgresql support the xor operator?
    
    You can get bitwise/binary xor (of bitstrings and integers) with the #
    operator AFAICS.
    
    
    
  3. Re: XOR operator.

    Jean-Luc Lachance <jllachan@nsd.ca> — 2003-03-29T21:00:02Z

    AFAICR
    
    A xor B = ( A and not B) or ( not A and B)
    
    It is a pain to write, but you can always:
    
    CREATE FUNCTION XOR( boolean, boolean) 
    RETURNS boolean as '
    RETURN ( $1 and not $2) or ( not $1 and $2);
    ' LANGUAGE 'plpgsql';
    
    
    
    Stephan Szabo wrote:
    > 
    > On Fri, 28 Mar 2003, Joshua Moore-Oliva wrote:
    > 
    > > Does postgresql support the xor operator?
    > 
    > You can get bitwise/binary xor (of bitstrings and integers) with the #
    > operator AFAICS.
    > 
    > ---------------------------(end of broadcast)---------------------------
    > TIP 2: you can get off all lists at once with the unregister command
    >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
    
    
    
  4. Re: XOR operator.

    Stephan Szabo <sszabo@megazone23.bigpanda.com> — 2003-03-29T21:15:18Z

    On Sat, 29 Mar 2003, Jean-Luc Lachance wrote:
    
    > AFAICR
    >
    > A xor B = ( A and not B) or ( not A and B)
    
    Unless I misremember, for simple booleans
    A xor B can be expressed as A!=B.  That's why I'd
    guessed he was looking for bitwise/binary xor.