Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    13

    Unanswered: Bitwise operators for the numeric datatype

    Is there no support at all for using bitwise operators such as AND on the numeric data type in PostgreSQL? I get this error message when running some code:

    Code:
    operator does not exist: numeric & numeric
    Now I can hack together a solution by dividing both numerics into arrays of bigints and do the operations on them and put them back together. But I can't believe that there really wouldn't be a function or operator for this already.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    What about showing us your SQL query and your table definitions - my crystal ball is broken right now and I can't see your screen from over here.

    According to the manual & is the bitwise and, so there must be something else you are not telling us - my guess are wrong datatypes:

    Code:
    psql (9.1.4)
    Type "help" for help.
    
    postgres=> select 4 & 1;
     ?column?
    ----------
            0
    (1 row)
    
    postgres=> select 4 & 4;
     ?column?
    ----------
            4
    (1 row)
    postgres=> select 4 | 1;
     ?column?
    ----------
            5
    (1 row)
    postgres=>
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •