Logical bitwise operator

Hi ALL
Logical bitwise comparison operator 'O' is used between two operands say A and B as "A O B".
A is of type INT1 and B is of type X.
The above mentioned line was working fine till enabling unicode check. But now it says A should be of type X or Xstring.A's type cannot be changed since it is derived from a std structure.
Is there some other operator which does the same function as operator 'O'?
Regards,
Navaneeth

Hi,
Check this..
IF.....XOR.....
Regards
Vijay

Similar Messages

  • Does bitwise operation on boolean datatypes work like logical operation ?

    Does bitwise operation on boolean datatypes work like logical operation ?
    For example, in the following code, how is each bitwise operation (say) 'b1 & b2' evaluated ?
    1) by converting the values of b1 (true) and b2 (false) to binary and doing '&' on them OR
    2) just treating it as a logical operation (i.e. similar to &&) where both have to be equal to be true
    Also, does the outcome of the if condition need to result in a 'true' or 'false' for the relevant message to print ? ....... Just fyi, I tried out this program and it goes to condition 2 but I do not understand why.
    class SSBool {
    public static void main(String[] args) {
    boolean b1 = true;
    boolean b2 = false;
    boolean b3 = true;
    if (b1 & b2 | b2 & b3 | b2)
    System.out.println ("condition 1");
    if (b1 & b2 | b2 & b3 | b2 | b1)
    System.out.println ("condition 2");
    Thank you,
    AG

    The Java Tutorial (always my first stop if I need an answer) says :
    "When both operands are boolean, the operator & performs the same operation as &&."
    That your program goes to condition 2 is obvious because the last test in the if-clause if (b1 & b2 | b2 & b3 | b2 | b1) looks at b1 which is true...

  • Bitwise Operator ( ) help

    I'm a new beginner and I have some problems with such code:
    class Test {
         public static void main(String[] args) {
              int i = -1;
              int a = i;
              for ( int k = 0 ; k < 32 ; k ++ ) {
                   i = i >>> 1;
                   System.out.print(i+" ");
                   System.out.println(a >>> (k+1) );
    I hope that the two columns of the output wil be the same, but the
    last line isn't.
    Why a == -1 after " int a = -1; a = a >>> 32 " ? I think a should be 0.
    Am I right or is there any mistake?

    See the language spec:
    http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#5121
    in particular:
    If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (�15.22.1) with the mask value 0x1f. The shift distance actually used is therefore always in the range 0 to 31, inclusive.
    Though it doesn't say why.

  • Logical XOR operator in T-SQL (SQL Server 2000)

    Hi all....
    I was wondering why SQL Server 2000 lacks a logical XOR operator. Do you have a ready to use function that implements it?
    How can I program one by myself? I know that A XOR B is equivalent to NOT A * B + A * NOT B. So I tried to create this function :
    CREATE FUNCTION XOR
    -- Add the parameters for the function here
    @A BIT,
    @B BIT
    RETURNS BIT
    AS
    BEGIN
    RETURN NOT @A AND @B OR @A + NOT @B
    END
    But it didn't compile.
    How can I pass boolean values as parameters? any other hint?
    Thanks
    Jaime

    I have these two views , one of them hard coded as NULL as it always needs to be NULL. I wanted to union them
    Now the problem is I have to replace those NULLS if I have a value from other VIEW or else NULL ( no change)
    I am getting duplicates of rows with values and NULLS , whereas I needed only records with values
    I need records with values and records without value as NULL . please let me know how to eliminate dups with NULLS
    21
    ARGH
    Bus    
    NULL
    NULL
    NULL
    NULL
    21
    ARGH
    Bus
    66
    781
    HEAVY
    00:00.0
    21
    F1WS
    Ship
    NULL
    NULL
    NULL
    NULL
    21
    HGDD
    car
    NULL
    NULL
    NULL
    NULL
    21
    HGDT
    car
    NULL
    NULL
    NULL
    NULL
    Below is the code :
    --- view having values
    SELECT *
    FROM Table1 AS S INNER JOIN
    Table2 AS P ON S.columnA = P.columnB
    WHERE EXISTS
    (SELECT 1 AS A
    FROM Table2 AS R
    WHERE (S.columnA = columnB))
    GROUP BY ALL
    UNION
    --- views harded coded as NULLS
    SELECT *, NULL AS APR , NULL AS MAY , NULL AS JUN , NULL AS JUL , NULL AS AUG
    FROM Table1 AS S INNER JOIN
    Table2 AS P ON S.columnA <> P.columnB
    WHERE (NOT EXISTS
    (SELECT 1 AS A
    FROM Table2 AS R
    WHERE (S.columnA = columnB) )) OR
    EXISTS
    (SELECT 1 AS A
    FROM Table2 AS R
    WHERE (S.columnA = columnB) )
    GROUP BY ALL

  • How to get a column by applying logical AND operator on two column ?

    All column are VARCHAR2 data type.
    I have table output in this way :
    col1 col2
    True True
    True False
    False FalseBut i want a additional column in this way :
    col1 col2 result
    True True True
    True False False
    False False FalseAs the output indicates its clear that resut column is logical AND operator
    on col1 and col2. How to achieve this ?

    try this
    WITH logic AS
         (SELECT 'TRUE' col1, 'TRUE' col2
            FROM DUAL
          UNION ALL
          SELECT 'TRUE' col1, 'FALSE' col2
            FROM DUAL
          UNION ALL
          SELECT 'FALSE' col1, 'TRUE' col2
            FROM DUAL
          UNION ALL
          SELECT 'FALSE' col1, 'FALSE' col2
            FROM DUAL)
    SELECT col1, col2,
           CASE
              WHEN 'FALSE' IN (col1, col2)
                 THEN 'FALSE'
              ELSE 'TRUE'
           END AS log_and,
           CASE
              WHEN 'TRUE' IN (col1, col2)
                 THEN 'TRUE'
              WHEN 'FALSE' IN (col1, col2)
                 THEN 'FALSE'
           END AS log_or
      FROM logic 
    Explain complete.
    PLAN_TABLE_OUTPUT                                                              
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)|                 
    |   0 | SELECT STATEMENT |      |     4 |    32 |     8   (0)|                 
    |   1 |  VIEW            |      |     4 |    32 |     8   (0)|                 
    |   2 |   UNION-ALL      |      |       |       |            |                 
    |   3 |    FAST DUAL     |      |     1 |       |     2   (0)|                 
    |   4 |    FAST DUAL     |      |     1 |       |     2   (0)|                 
    |   5 |    FAST DUAL     |      |     1 |       |     2   (0)|                 
    |   6 |    FAST DUAL     |      |     1 |       |     2   (0)|                 
    Note                                                                           
       - 'PLAN_TABLE' is old version                                               
    16 rows selected.regards,
    friend

  • What is the difference between != and Logical NOT operator

    kindly,tell me what is the difference between Not Equality operator and logical negation operator.
    Edited by: user13414134 on Dec 3, 2010 8:59 AM

    what is the difference between != and Logical NOT operator The NOT operator is transformed into the inequality operator (&lt;>), as can be seen from the Predicate Information of the explain plan:
    SQL> explain plan for select * from dual where  :x != :y
    Explain complete.
    SQL> select * from table(dbms_xplan.display())
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 3752461848                                                    
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |    
    |   0 | SELECT STATEMENT   |      |     1 |     2 |     2   (0)| 00:00:01 |    
    |*  1 |  FILTER            |      |       |       |            |          |    
    |   2 |   TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |    
    Predicate Information (identified by operation id):                            
       1 - filter(:Y&lt;>:X)                                                          
    14 rows selected.
    SQL> explain plan for select * from dual where not :x = :y
    Explain complete.
    SQL> select * from table(dbms_xplan.display())
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 3752461848                                                    
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |    
    |   0 | SELECT STATEMENT   |      |     1 |     2 |     2   (0)| 00:00:01 |    
    |*  1 |  FILTER            |      |       |       |            |          |    
    |   2 |   TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |    
    Predicate Information (identified by operation id):                            
       1 - filter(:Y&lt;>:X)                                                          
    14 rows selected.

  • Bitwise operator question...

    Hi,all.
    I have been using Java for around 1 year, but still not very comfortable with bitwise problems. I wish some one can give me a thorough explanation for these. Better yet, if you know how to use bitwise operator to solove the real programming problem, please post here too. I am doing some testing now. I will post some coding example later here, so you may help me on these coding too.
    Everyone have a great sunday night.

    Integers are represented by 32-bit values. You can have either 'signed' or 'unsigned' integer ranges.
    signed int 32000 to - 32000
    unsigned int 0 to 65000
    (note, these are approximations)
    For signed interpretations, the last digit on the left hand side represents wether or not the value is negative (called the most significant bit, msb).
    1000 0000
    The '1' is the msb
    Steps to convert -14 to its binary representation (using 2s complement as explained by above post):
    1. write the binary representation of '1' (ignore negative for now)
    2. invert the values
    3. add 1
    1) 0000 1110
    2) 1111 0001
    3) 1111 0010
    As you can see, the msb is a '1', so therefore it represents a negative value
    Note: In binary addition,
    1 + 1 = 0 carry 1
    1 + 0 = 1
    0 + 0 = 0
    As for other applications of this, I find myself using bitwise calculations in graphical work.
    As stated above (I love to reiterate others words, cause it's fun!!), Assembler language programming is a fantastic way to become an expert in the art of bitwise manipulation (if you have the patience).

  • Pda reproducible bug with logical shift operation when y 3 for arrays

    Folks,
    I have discovered a problem and wonder if this is a wider bug or if I am doing something wrong:
    Labview PDA 8.0.1  -  running on a Dell Axim:
    I create a 2x1000 array of U32 and feed it as x into the logical shift operator.  If  y is between -3 and 3, the logical shift works properly.  If y >= 4 or <= -4, then the array is returned with all zeros.
    I have reproduced this for I32 data and smaller arrays.  Logical shift works properly for scalars.
    Has anyone else seen this?  Is this a bug?
    Thanks for any help.

    It might very well be a bug. If it works differently on the PC and on the PDA then it is almost certainly one.
    I suggest you post a simple example showing this so that people with current versions of the PDA module (i.e. not me) can test this. Maybe it was even fixed for 8.2?
    Try to take over the world!

  • How to make Bitwise operation in Labview ?

    Hello.. everyone,
    I need to make the bitwise operation (or) in Labview, but I can't find it somewhere!!!
    Anybody has the experiece about it, pls help me !!
    Thanks a lot

    Hi Nok,
    The standard OR function in the boolean sub palette of the functions palette performs a bitwise operation on it's input data. This is a polymorphic function so you can input scalar booleans, arrays of booleans or numerics.
    Hope this helps,
    Nick

  • Logical OR operator

    Hi,
    Anyone can help how to solve the following ..
    System.out.println( 4 | 7);
    I have tried with logical opertor (0100 OR 0111) with result 11 !!
    but the answer was 7 ????.
    -Alex

    It is not logical but numerical operator in this case. Indeed,
    System.out.println( 4 || 7);does not even compile.
    Gooc old C does not have a logical (boolean) type, it uses integers on the syntax level too. C++ has the "bool" type, but it maintains the logical <-> integer conversion.
    In java the logical type is separated from the integral ones; there is no boolean -> integer conversion.
    For convenience however single & and | can be applied to booleans.

  • LPX-00601: Invalid token in: using logical AND operator in XQuery

    Hi Pro's,
    I am working on DB version 10.2.0.3, I have loaded this document into XMLType column:
    <ROOT>
    <COUNTRY>
    <NAME>India</NAME>
    <PERSON>
    <NAME>Harinath</NAME>
    <CITY>Bangalore</CITY>
    <STATE>Karnataka</STATE>
    <IMMI_STATUS>Citizen</IMMI_STATUS>
    </PERSON>
    <PERSON>
    <NAME>Mohan</NAME>
    <CITY>Kakinada</CITY>
    <STATE>Andhra Pradesh</STATE>
    <IMMI_STATUS>Citizen</IMMI_STATUS>
    </PERSON>
    </COUNTRY>
    <COUNTRY>
    <NAME>USA</NAME>
    <PERSON>
    <NAME>Drew P</NAME>
    <CITY>Appleton</CITY>
    <STATE>WI</STATE>
    <IMMI_STATUS>Citizen</IMMI_STATUS>
    </PERSON>
    <PERSON>
    <NAME>Bush</NAME>
    <CITY>Washington</CITY>
    <STATE>DC</STATE>
    <IMMI_STATUS>Citizen</IMMI_STATUS>
    </PERSON>
    <PERSON>
    <NAME>Harinath</NAME>
    <CITY>Atlanta</CITY>
    <STATE>GA</STATE>
    <IMMI_STATUS>Alien</IMMI_STATUS>
    </PERSON>
    </COUNTRY>
    </ROOT>
    This query returns one row : (As Expected)
    ===============================
    SELECT extractValue(rec.xmldata, '/ROOT/COUNTRY[PERSON/NAME="Drew P"]/NAME') C_COUNTRY
    FROM (SELECT VALUE(xml) xmldata
    FROM XXSSI_XML_STG stg
    ,TABLE(XMLSequence(extract(stg.XMLDATA, '//ROOT'))) xml
    WHERE stg.REQUEST_ID = 4204203) rec
    This query fails: TRUE as "Harinath" appears twice in the document once in "India" and once in "USA";
    ======================================================
    SELECT extractValue(rec.xmldata, '/ROOT/COUNTRY[PERSON/NAME="Harinath"]/NAME') C_COUNTRY
    FROM (SELECT VALUE(xml) xmldata
    FROM XXSSI_XML_STG stg
    ,TABLE(XMLSequence(extract(stg.XMLDATA, '//ROOT'))) xml
    WHERE stg.REQUEST_ID = 4204203) rec ;
    To fix the error I introduced "LOGICAL AND" in the XPath: THIS FAILS
    ===================================================
    SELECT extractValue(rec.xmldata, '/ROOT/COUNTRY[PERSON/NAME="Harinath" AND IMMI_STATUS="Citizen"]/NAME') C_COUNTRY
    FROM (SELECT VALUE(xml) xmldata
    FROM XXSSI.XXSSI_XML_STG stg
    ,TABLE(XMLSequence(extract(stg.XMLDATA, '//ROOT'))) xml
    WHERE stg.REQUEST_ID = 4204203) rec ;
    Please help!!!!!!

    Hi !!!
    Im sooo thankful to you... it works!!!
    Learnt a lesson today "dont blindly go by those user guides" I was refering to Example 6–8 of "B14259" 10g Developer Guide (Page 282) which has this query
    SELECT extract(OBJECT_VALUE, '/PurchaseOrder/Item').getClobval()
    FROM mypurchaseorders p
    WHERE existsNode(OBJECT_VALUE,
    '/PurchaseOrder[PONum=1001 AND Company = "Oracle Corp"]') = 1;
    may be a printing error :(
    Thanks a lot.

  • BitWise Operations in java

    hi Guys
    Can any one help me out in explaining the below program
    public class Bitwise{
    public static void main (String[]args){
    int x=12&13;
    int y=x^6;
    System.out.println(y I 3)
    Pls help me with the above program in detail explanation
    Raghu

    Here's a better idea. You start by:
    1) adding print statements to print out x and y immediately after they're set.
    2) predicting what you think each print statement will produce, consulting your favorite text or tutorial (see below links) or the JLS if you need to.
    3) running the program.
    4) seeing if the results match what you expected.
    5) trying to figure why they didn't match, if they didn't.
    6) poting a specific question here about what you expected and why, and what you saw instead, if you're unable to figure it out.
    Installation Notes - JDK 5.0 Microsoft Windows (32-bit)
    Your First Cup of Java
    New to Java Center
    The Java&#8482; Tutorial - A practical guide for programmers
    The Java&#8482; Tutorial - Trail: Learning the Java Language
    Java Programming Notes - Fred Swartz
    How To Think Like A Computer Scientist
    Introduction to Computer Science using Java
    The Java Developers Almanac 1.4
    Object-Oriented Programming Concepts
    Object-oriented language basics
    Don't Fear the OOP
    Books:
    The Java Programming Language - 4th Edition
    Head First Java, by Bert Bates and Kathy Sierra
    Thinking in Java (Free online), by Bruce Eckel
    Core Java, by Cay Horstmann and Gary Cornell
    Effective Java, by Joshua Bloch
    http://java.sun.com/developer/Books/javaprogramming/
    Intermediate
    The Craftsman Series
    Java Design: Building Better Apps and Applets (2nd Edition)
    Head First Design Patterns

  • Bitwise operator: (010|4)

    Executing the following code results in "12". I do not understand why?
    public class Test {
        public static void main(String[] args) {
            System.out.println(010|4);
    }From what I understand, the answer should be 6. What is wrong with my below logic?
    010 = 2
    100 = 4
    110 = 6
    Thanks!

    You can check out the JLS - go here:
    http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html
    And look at section 3.10.1
    There's no way to explicitly enter a base 2 digit (that I know of) - you can specify it as base 16 by prepending with a 0x, or octal by prepending with a 0. You could use the Integer.parseInt(value, radix) method to do this by passing in the binary digit string and a radix of 2, as int value = Integer.parseInt("010", 2)I hope that helped
    Lee

  • Bitwise Operator

    Hi Gurus,
    I am bit poor at math and yes i know bitand is used for binary and operation. But i can't figure out this conversion.
    Here is a flag column values from ts$
    flags   0x40 = COMPRESS
             0x10000 = OLTP Compression
             0x20000 = Columnar Low Compression
             0x40000 = Columnar High Compression
             0x80000 = Archive CompressionAnd here is corrosponding conversion in dba_tablespaces script.
    case when bitand(ts.flags,  65536) = 65536  then 'OLTP'
                      when bitand(ts.flags, (131072+262144)) = 131072
                        then 'QUERY LOW'
                      when bitand(ts.flags, (131072+262144)) = 262144
                        then 'QUERY HIGH'
                      when bitand(ts.flags, (131072+262144)) = (131072+262144)
                        then 'ARCHIVE LOW'
                      when bitand(ts.flags, 524288) = 524288
                        then 'ARCHIVE HIGH'
                      else 'BASIC' end))Now, here are my question
    1. 0x40 & 0x10000 and othere are hexa values Right ?
    2. So what does 65536 means here all other values are multiple (131072) are of this
    3. So, what are we checking here with this kind of bitand(ts.flags, (131072+262144)) thing
    Can someone please explain in simple terms. I searched manuals and other but they give just high level information but not basic.

    decimal 65536 is the same as hexadecimal 10000
    You can test it useing a calculator or SQL
    select to_char(65536,'fmXXXXXX') hexConversion from dual;
    HEXCONVERSION
    10000BITAND is used to test if a certain bit is set or not. For example in your case it is used to test if the bits for ARCHIVE + LOW COMPRESSION are set.
    Hex 10000 in Binary code (not HEX) looks like this
    0x10000  => 0000100000000 .... many 0s
    0x20000  => 0001000000000 .... many 0s
    0x40000  => 0010000000000 .... many 0s
    0x80000  => 0100000000000 .... many 0s Bitand does a binary AND operation on each bit. Therefore it can be used to find out if certain bits are set or not.
    example
    1000111010001
    BITAND
    0000110000000
    0000110000000For each bit the AND operator works like this
    0 AND 0 = 0
    0 AND 1 = 0
    1 AND 0 = 0
    1 AND 1 = 1
    Edited by: Sven W. on Aug 30, 2010 5:45 PM

  • Using ModbusSlave and for bitwise operation

    I ran into a problem using a ModbusSlave to read a signed Integer for bitmasking.
    I connected the Tag value into D40001 and read the bits from ModbusSlave1.H40002.fx (for bits 0-15) and ModbusSlave1.H40001.fx (for bits 16-31).
    When the the MSB (Bit 15) was on, the number returned was a negative value, and the ModbusSlave showed no bits as set.
    I alos found this to be a problem using mod( int(WORD) , 2) --> to get Bit 0
                                                           mod( int(WORD/2) , 2) --> to get Bit 1...
    as this will return an error if WORD is negative.
    I saw a suggestion to check for the sign bit by: if ((WORD <0), TRUE, FALSE).
    How does this work if the sign bit is the only bit on (WORD = -0)?
    The solution we did was to create a new Tag in the PLC as a DINT (double INT-32 bit) and add a rung to move the INT(16 bit) into this new Tag.
    However I did find that this will be a problem if the MSB (bit 31) is used in the DINT.
    The getbit function worked but I was looking for a solution other than using this as I am often working from existing PLC's and don't always have access to the PLC program to make a change like this.

    Hello Khalid,
    The application is pretty simple.
    I am reading a tag from a AB Controllogix PLC.
    Lookout is seeing it as a 16 bit signed Integer.
    The tag has each bit assigned to a Photoeye or e-stop and I want to monitor each bit to see of it is true.
    It can be simulated using a Pot and ModbusSlave.
    I tried the "S" regsitered but did not see a value in the ModbusSlave1.H40002.fx.
    Should I use another connection?
    Dswift

Maybe you are looking for